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

Method constructor

extensions/amp-access/0.1/amp-access-source.js:52–126  ·  view source on GitHub ↗

* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc * @param {!JsonObject} configJson * @param {function():!Promise } readerIdFn * @param {function(time)} scheduleViewFn * @param {function(!Promise)} onReauthorizeFn * @param {!Element} accessElement

(
    ampdoc,
    configJson,
    readerIdFn,
    scheduleViewFn,
    onReauthorizeFn,
    accessElement
  )

Source from the content-addressed store, hash-verified

50 * @param {!Element} accessElement
51 */
52 constructor(
53 ampdoc,
54 configJson,
55 readerIdFn,
56 scheduleViewFn,
57 onReauthorizeFn,
58 accessElement
59 ) {
60 /** @const */
61 this.ampdoc = ampdoc;
62
63 /** @const */
64 this.getReaderId_ = readerIdFn;
65
66 /** @const */
67 this.scheduleView_ = scheduleViewFn;
68
69 /** @const */
70 this.onReauthorize_ = onReauthorizeFn;
71
72 /** @const */
73 this.accessElement_ = accessElement;
74
75 /** @const @private {boolean} */
76 this.isServerEnabled_ = isExperimentOn(ampdoc.win, 'amp-access-server');
77
78 /** @const @private {boolean} */
79 this.isJwtEnabled_ = isExperimentOn(ampdoc.win, 'amp-access-jwt');
80
81 /** @const {!AccessType} */
82 this.type_ = this.buildConfigType_(configJson);
83
84 /** @const {!JsonObject} */
85 this.loginConfig_ = this.buildConfigLoginMap_(configJson);
86
87 /** @const {?JsonObject} */
88 this.authorizationFallbackResponse_ =
89 configJson['authorizationFallbackResponse'];
90
91 /** @const {?string} */
92 this.namespace_ = configJson['namespace'] || null;
93
94 /** @const {!AccessTypeAdapterDef} */
95 this.adapter_ = this.createAdapter_(configJson);
96
97 /** @const @private {!../../../src/service/url-replacements-impl.UrlReplacements} */
98 this.urlReplacements_ = Services.urlReplacementsForDoc(accessElement);
99
100 /** @private @const {function(string):Promise<string>} */
101 this.openLoginDialog_ = openLoginDialog.bind(null, ampdoc);
102
103 /** @private {?JsonObject} */
104 this.authResponse_ = null;
105
106 const deferred = new Deferred();
107
108 /**
109 * This pattern allows AccessService to attach behavior to authorization

Callers

nothing calls this directly

Calls 4

buildConfigType_Method · 0.95
buildConfigLoginMap_Method · 0.95
createAdapter_Method · 0.95
isExperimentOnFunction · 0.50

Tested by

no test coverage detected