MCPcopy Create free account
hub / github.com/ampproject/amphtml / start

Method start

third_party/subscriptions-project/swg.js:10093–10142  ·  view source on GitHub ↗

* Starts the deferred account flow. * @return {!Promise<!DeferredAccountCreationResponse>}

()

Source from the content-addressed store, hash-verified

10091 * @return {!Promise<!DeferredAccountCreationResponse>}
10092 */
10093 start() {
10094 const entitlements = this.options_.entitlements;
10095
10096 // For now, entitlements are required to be present and have the Google
10097 // token. This is strictly not required for the implementation. But it's
10098 // preferrable API-wise at this time.
10099 if (!entitlements || !entitlements.getEntitlementForSource('google')) {
10100 throw new Error('No entitlements with "google" source');
10101 }
10102
10103 // Start/cancel events.
10104 this.deps_
10105 .callbacks()
10106 .triggerFlowStarted(SubscriptionFlows.COMPLETE_DEFERRED_ACCOUNT_CREATION);
10107
10108 this.activityIframeView_ = new ActivityIframeView(
10109 this.win_,
10110 this.activityPorts_,
10111 feUrl('/recoveriframe'),
10112 feArgs({
10113 'publicationId': this.deps_.pageConfig().getPublicationId(),
10114 'productId': this.deps_.pageConfig().getProductId(),
10115 'entitlements': (entitlements && entitlements.raw) || null,
10116 'consent': this.options_.consent,
10117 }),
10118 /* shouldFadeBody */ true
10119 );
10120
10121 this.openPromise_ = this.dialogManager_.openView(this.activityIframeView_);
10122 return this.activityIframeView_.acceptResult().then(
10123 (result) => {
10124 // The consent part is complete.
10125 return this.handleConsentResponse_(
10126 /** @type {!Object} */ (result.data)
10127 );
10128 },
10129 (reason) => {
10130 if (isCancelError(reason)) {
10131 this.deps_
10132 .callbacks()
10133 .triggerFlowCanceled(
10134 SubscriptionFlows.COMPLETE_DEFERRED_ACCOUNT_CREATION
10135 );
10136 } else {
10137 this.dialogManager_.completeView(this.activityIframeView_);
10138 }
10139 throw reason;
10140 }
10141 );
10142 }
10143
10144 /**
10145 * @param {!Object} data

Callers

nothing calls this directly

Calls 15

feUrlFunction · 0.85
feArgsFunction · 0.85
isCancelErrorFunction · 0.85
triggerFlowStartedMethod · 0.80
callbacksMethod · 0.80
getPublicationIdMethod · 0.80
pageConfigMethod · 0.80
getProductIdMethod · 0.80
triggerFlowCanceledMethod · 0.80
completeViewMethod · 0.80

Tested by

no test coverage detected