@alipay/ams-checkout 0.0.1693912790-dev.1 → 0.0.1693912790-dev.2

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.
@@ -1,5 +1,5 @@
1
1
  import { componentSignEnum, Ianalytics } from '../../types';
2
- export declare const getAppPath: (environment: string | undefined, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
2
+ export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
3
3
  export declare const getAppDomain: (domainParams: {
4
4
  environment: string;
5
5
  appVersion: string;
@@ -29,10 +29,11 @@ export default class ComponentApp {
29
29
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
30
30
  */
31
31
  setRender(createIframeNode: (context: ComponentApp, params: IcreateComponent) => Promise<void>): void;
32
+ initAPSecurity(): void;
32
33
  /**
33
34
  * @description render iframe content
34
35
  */
35
- appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, CashierSdkActionQueryResult | null]>;
36
+ appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, CashierSdkActionQueryResult]>;
36
37
  /**
37
38
  * @description Interface request
38
39
  */
@@ -24,6 +24,7 @@ import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
24
24
  import { isLocalMock } from "../../util/mock";
25
25
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
26
  import { componentAddCSS } from "./component.style";
27
+ import APDID from '@alipay/jshield-apdid';
27
28
  var _window = window,
28
29
  innerHeight = _window.innerHeight;
29
30
  var amsSetSize = function amsSetSize(event, dom) {
@@ -106,6 +107,20 @@ var ComponentApp = /*#__PURE__*/function () {
106
107
  value: function setRender(createIframeNode) {
107
108
  this.createIframeNode = createIframeNode;
108
109
  }
110
+ }, {
111
+ key: "initAPSecurity",
112
+ value: function initAPSecurity() {
113
+ var _this$_renderParams, _this$_renderParams$p;
114
+ var securityConfig = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : (_this$_renderParams$p = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams$p === void 0 ? void 0 : _this$_renderParams$p.securityConfig;
115
+ if (!securityConfig) {
116
+ return;
117
+ }
118
+ APDID.initToken(securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName, {
119
+ host: securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway
120
+ }, function (success, tokenResult, msg) {
121
+ console.log("initToken result tokenResult", JSON.stringify(tokenResult));
122
+ });
123
+ }
109
124
 
110
125
  /**
111
126
  * @description render iframe content
@@ -123,6 +138,7 @@ var ComponentApp = /*#__PURE__*/function () {
123
138
  key: 'sdk_create_component',
124
139
  value: Date.now()
125
140
  });
141
+ this.initAPSecurity();
126
142
  this.createRetentionPopup();
127
143
  this.createMockup();
128
144
  if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
@@ -153,7 +169,7 @@ var ComponentApp = /*#__PURE__*/function () {
153
169
  value: Date.now()
154
170
  });
155
171
  this._actionQueryPromise = new Promise(function (resolve, reject) {
156
- var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
172
+ var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3, _this2$_renderParams4, _this2$_renderParams5;
157
173
  var params = {
158
174
  paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
159
175
  paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
@@ -164,17 +180,28 @@ var ComponentApp = /*#__PURE__*/function () {
164
180
  if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
165
181
  params.paymentMethodType = 'CARD';
166
182
  }
183
+ var needDeviceId = false;
184
+ var securityConfig = (_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : (_this2$_renderParams5 = _this2$_renderParams4.paymentSessionMetaData) === null || _this2$_renderParams5 === void 0 ? void 0 : _this2$_renderParams5.securityConfig;
185
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign && securityConfig) {
186
+ var _this2$_renderParams6, _this2$_renderParams7;
187
+ var extendInfo = ((_this2$_renderParams6 = _this2._renderParams) === null || _this2$_renderParams6 === void 0 ? void 0 : (_this2$_renderParams7 = _this2$_renderParams6.paymentSessionMetaData) === null || _this2$_renderParams7 === void 0 ? void 0 : _this2$_renderParams7.extendInfo) || '';
188
+ var info = JSON.parse(extendInfo);
189
+ if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
190
+ needDeviceId = true;
191
+ }
192
+ }
193
+
167
194
  /**
168
195
  * @description easyPay
169
196
  */
170
197
  if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
171
- var _this2$_renderParams4;
198
+ var _this2$_renderParams8;
172
199
  var _ref = params.paymentSessionConfig || {},
173
200
  _ref$productSceneVers = _ref.productSceneVersion,
174
201
  productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
175
202
  _ref$productScene = _ref.productScene,
176
203
  productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
177
- var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
204
+ var _ref2 = ((_this2$_renderParams8 = _this2._renderParams) === null || _this2$_renderParams8 === void 0 ? void 0 : _this2$_renderParams8.paymentSessionMetaData) || {},
178
205
  _ref2$action = _ref2.action,
179
206
  _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
180
207
  _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
@@ -192,8 +219,8 @@ var ComponentApp = /*#__PURE__*/function () {
192
219
  * @description autoDebit
193
220
  */
194
221
  if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
195
- var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
196
- var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
222
+ var _this2$_renderParams9, _this2$_renderParams10, _action$web, _action$wap;
223
+ var action = ((_this2$_renderParams9 = _this2._renderParams) === null || _this2$_renderParams9 === void 0 ? void 0 : (_this2$_renderParams10 = _this2$_renderParams9.paymentSessionMetaData) === null || _this2$_renderParams10 === void 0 ? void 0 : _this2$_renderParams10.action) || {};
197
224
  var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
198
225
  if (signType === 'SMS') {
199
226
  return resolve({
@@ -217,7 +244,8 @@ var ComponentApp = /*#__PURE__*/function () {
217
244
  }
218
245
  queryPaymentInfo(params, {
219
246
  env: _this2.AMSSDK.options.env.environment,
220
- locale: _this2.AMSSDK.options.locale
247
+ locale: _this2.AMSSDK.options.locale,
248
+ needDeviceId: needDeviceId
221
249
  }).then(function (res) {
222
250
  _this2._performanceData.push({
223
251
  key: 'sdk_action_query_end',
@@ -618,7 +646,7 @@ var ComponentApp = /*#__PURE__*/function () {
618
646
  key: "sendRenderEvent",
619
647
  value: function () {
620
648
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
621
- var _this$_renderParams, _this$_renderParams2, res;
649
+ var _this$_renderParams2, _this$_renderParams3, res;
622
650
  return _regeneratorRuntime().wrap(function _callee$(_context) {
623
651
  while (1) switch (_context.prev = _context.next) {
624
652
  case 0:
@@ -642,8 +670,8 @@ var ComponentApp = /*#__PURE__*/function () {
642
670
  event: 'renderComponent',
643
671
  data: {
644
672
  queryResult: res,
645
- sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
646
- paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
673
+ sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
674
+ paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.paymentSessionData,
647
675
  heightOfVisible: Math.max(innerHeight, window.innerHeight),
648
676
  envInfo: {
649
677
  screenHeight: screen.height,
@@ -19,6 +19,7 @@ import { sdkVersion } from "../config/index";
19
19
  import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
20
20
  import { ERROR } from "../types";
21
21
  import { get } from "../util/get";
22
+ import { getApdidToken } from "../util/security";
22
23
  import axios from 'axios';
23
24
  import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
24
25
  var _queryParse = queryParse(),
@@ -63,7 +64,7 @@ export function request(_x, _x2) {
63
64
  }
64
65
  function _request() {
65
66
  _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestData, options) {
66
- var myRequest, startTime, envInfo, _navigator, _data, _yield$myRequest, data, headers, resData, traceId, handleGetWayError, _error$message, _error, timeoutCode, errorCode;
67
+ var myRequest, startTime, envInfo, deviceId, _navigator, _data, _yield$myRequest, data, headers, resData, traceId, handleGetWayError, _error$message, _error, timeoutCode, errorCode;
67
68
  return _regeneratorRuntime().wrap(function _callee$(_context) {
68
69
  while (1) switch (_context.prev = _context.next) {
69
70
  case 0:
@@ -83,6 +84,16 @@ function _request() {
83
84
  screenHeight: screen.height,
84
85
  timeZoneOffset: new Date().getTimezoneOffset()
85
86
  };
87
+ if (!(options !== null && options !== void 0 && options.needDeviceId)) {
88
+ _context.next = 8;
89
+ break;
90
+ }
91
+ _context.next = 6;
92
+ return getApdidToken('Acquirer');
93
+ case 6:
94
+ deviceId = _context.sent;
95
+ envInfo.deviceId = deviceId;
96
+ case 8:
86
97
  try {
87
98
  envInfo.browserInfo.browserJavaEnabled = ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.javaEnabled()) || false;
88
99
  // eslint-disable-next-line no-empty
@@ -94,12 +105,12 @@ function _request() {
94
105
  refUrl: window.location.href
95
106
  }
96
107
  })] : [requestData];
97
- _context.prev = 6;
98
- _context.next = 9;
108
+ _context.prev = 11;
109
+ _context.next = 14;
99
110
  return myRequest({
100
111
  data: _data
101
112
  });
102
- case 9:
113
+ case 14:
103
114
  _yield$myRequest = _context.sent;
104
115
  data = _yield$myRequest.data;
105
116
  headers = _yield$myRequest.headers;
@@ -108,7 +119,7 @@ function _request() {
108
119
  resData.traceId = traceId || '';
109
120
  handleGetWayError = fomatGetwayError(headers, traceId);
110
121
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
111
- _context.next = 18;
122
+ _context.next = 23;
112
123
  break;
113
124
  }
114
125
  throw new Error(JSON.stringify({
@@ -116,11 +127,11 @@ function _request() {
116
127
  errorCode: handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode,
117
128
  success: false
118
129
  }));
119
- case 18:
130
+ case 23:
120
131
  return _context.abrupt("return", resData);
121
- case 21:
122
- _context.prev = 21;
123
- _context.t0 = _context["catch"](6);
132
+ case 26:
133
+ _context.prev = 26;
134
+ _context.t0 = _context["catch"](11);
124
135
  // eslint-disable-next-line no-console
125
136
  console.log('request error', _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message);
126
137
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
@@ -135,11 +146,11 @@ function _request() {
135
146
  errorCode: errorCode,
136
147
  errorMessage: ''
137
148
  }));
138
- case 28:
149
+ case 33:
139
150
  case "end":
140
151
  return _context.stop();
141
152
  }
142
- }, _callee, null, [[6, 21]]);
153
+ }, _callee, null, [[11, 26]]);
143
154
  }));
144
155
  return _request.apply(this, arguments);
145
156
  }
@@ -25,4 +25,4 @@ export declare const fomatGetwayError: (headers: Record<string, any>, traceId: s
25
25
  memo: string;
26
26
  };
27
27
  resultStatus: any;
28
- } | null;
28
+ };
@@ -62,8 +62,18 @@ interface IpaymentSessionConfig {
62
62
  paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
63
63
  productSceneVersion: string;
64
64
  }
65
+ interface IpaymentSecurityConfig {
66
+ appId: string;
67
+ appName: string;
68
+ bizToken: string;
69
+ gateway: string;
70
+ h5gateway: string;
71
+ tokenCollectTime: string;
72
+ workSpaceId: string;
73
+ }
65
74
  export interface IpaymentSessionMetaData {
66
75
  paymentSessionConfig?: IpaymentSessionConfig;
76
+ securityConfig?: IpaymentSecurityConfig;
67
77
  moneyView?: any;
68
78
  extendInfo?: string;
69
79
  paymentMethodInfoView?: any;
@@ -178,6 +188,7 @@ export interface RequestConfig {
178
188
  beforerRequest?: () => void;
179
189
  afterRequest?: () => void;
180
190
  needEnvInfo?: boolean;
191
+ needDeviceId?: boolean;
181
192
  locale?: string;
182
193
  hostSign?: string;
183
194
  }
@@ -19,7 +19,7 @@ declare const getViewPort: (key: string) => any;
19
19
  declare const getOrigin: () => string;
20
20
  declare const serialize: (obj: Record<string, string>) => string;
21
21
  declare const isJsonString: (str: string) => boolean;
22
- declare const isDom: (obj: any) => any;
22
+ declare const isDom: (obj: any) => boolean;
23
23
  declare const device: {
24
24
  iOS: boolean;
25
25
  Android: boolean;
@@ -46,7 +46,7 @@ declare const fomatGetwayError: (headers: Record<string, any>, traceId: string)
46
46
  memo: string;
47
47
  };
48
48
  resultStatus: any;
49
- } | null;
49
+ };
50
50
  declare const isPC: () => boolean;
51
51
  declare const queryParse: (url?: string) => Record<string, any>;
52
52
  declare const getDesignFontSize: () => number;
@@ -0,0 +1,7 @@
1
+ export declare enum securityHost {
2
+ SG = "http://iopengw-9395.sggz00b.dev.alipay.net/api/open/risk_client",
3
+ US = "http://iopengw-5506.gz00b.dev.alipay.net/api/open/risk_client",
4
+ DE = "http://iopengw-910.degz00b.dev.alipay.net/api/open/risk_client"
5
+ }
6
+ export declare const getSecurityConfig: () => string;
7
+ export declare const getApdidToken: (scene: string) => Promise<string>;
@@ -0,0 +1,38 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import APDID from '@alipay/jshield-apdid';
6
+ export var securityHost = /*#__PURE__*/function (securityHost) {
7
+ securityHost["SG"] = "http://iopengw-9395.sggz00b.dev.alipay.net/api/open/risk_client";
8
+ securityHost["US"] = "http://iopengw-5506.gz00b.dev.alipay.net/api/open/risk_client";
9
+ securityHost["DE"] = "http://iopengw-910.degz00b.dev.alipay.net/api/open/risk_client";
10
+ return securityHost;
11
+ }({});
12
+ export var getSecurityConfig = function getSecurityConfig() {
13
+ return '';
14
+ };
15
+ export var getApdidToken = /*#__PURE__*/function () {
16
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(scene) {
17
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
21
+ try {
22
+ APDID.getApdidToken(scene, function (tokenResult) {
23
+ resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
24
+ });
25
+ } catch (error) {
26
+ reject('');
27
+ }
28
+ }));
29
+ case 1:
30
+ case "end":
31
+ return _context.stop();
32
+ }
33
+ }, _callee);
34
+ }));
35
+ return function getApdidToken(_x) {
36
+ return _ref.apply(this, arguments);
37
+ };
38
+ }();
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@alipay/ams-checkout","version":"0.0.1693912790-dev.1","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
1
+ {"name":"@alipay/ams-checkout","version":"0.0.1693912790-dev.2","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@alipay/jshield-apdid":"^2.0.3","@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}