@schibsted/account-sdk-browser 5.2.5 → 5.2.7
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/LICENSE.md +1 -1
- package/README.md +14 -15
- package/es5/global.js +92 -59
- package/es5/global.js.map +1 -1
- package/es5/global.min.js +1 -1
- package/es5/global.min.js.map +1 -1
- package/es5/identity.js +7 -2
- package/es5/identity.js.map +1 -1
- package/es5/identity.min.js +1 -1
- package/es5/identity.min.js.map +1 -1
- package/es5/index.js +92 -59
- package/es5/index.js.map +1 -1
- package/es5/index.min.js +1 -1
- package/es5/index.min.js.map +1 -1
- package/es5/monetization.js +562 -534
- package/es5/monetization.js.map +1 -1
- package/es5/monetization.min.js +1 -1
- package/es5/monetization.min.js.map +1 -1
- package/es5/payment.js +1 -1
- package/es5/payment.js.map +1 -1
- package/es5/payment.min.js.map +1 -1
- package/identity.js +1 -1
- package/index.js +1 -1
- package/monetization.js +1 -1
- package/package.json +3 -6
- package/payment.js +1 -1
- package/src/identity.js +3 -0
- package/src/monetization.js +18 -6
- package/src/payment.d.ts +1 -1
- package/src/payment.js +1 -1
- package/src/version.js +2 -2
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2026 Schibsted Products & Technology AS
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
4
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
package/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-

|
|
1
|
+

|
|
4
2
|
[](https://codecov.io/gh/schibsted/account-sdk-browser)
|
|
5
3
|
[](https://snyk.io/test/github/schibsted/account-sdk-browser)
|
|
6
4
|
|
|
@@ -53,9 +51,9 @@ Follow the [migration guide](./MIGRATION.md).
|
|
|
53
51
|
## Example project
|
|
54
52
|
|
|
55
53
|
There is an example that demonstrates how the SDK can be used. The code is
|
|
56
|
-
[here](https://
|
|
54
|
+
[here](https://schibsted.ghe.com/user-identity/sdk-example), and you can see it live
|
|
57
55
|
[here](https://pro.sdk-example.com). You have a use-case that we haven't thought of? Ask us to add
|
|
58
|
-
it by creating an [issue](https://
|
|
56
|
+
it by creating an [issue](https://schibsted.ghe.com/user-identity/sdk-example/issues/new).
|
|
59
57
|
|
|
60
58
|
You can use that code as inspiration or just fork and play with it. The account-sdk-browser NPM
|
|
61
59
|
module is used for authenticating the user with Schibsted account. Take a look at how the SDK is
|
|
@@ -184,7 +182,7 @@ signal to your main page — using
|
|
|
184
182
|
[postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) or something
|
|
185
183
|
similar — to indicate that the user is logged in. If the popup window fails to open, it'll
|
|
186
184
|
automatically fall back to the redirect flow. The SDK Example project mentioned above demonstrates
|
|
187
|
-
how it can work. Again, you can see [sdk-example](https://
|
|
185
|
+
how it can work. Again, you can see [sdk-example](https://schibsted.ghe.com/user-identity/sdk-example) if you
|
|
188
186
|
want a working example.
|
|
189
187
|
|
|
190
188
|
#### Is the user logged in?
|
|
@@ -312,23 +310,24 @@ browser side. Nevertheless, here is a short description of them.
|
|
|
312
310
|
* `referer` (yep, missing the double "rr"..): If this is missing, a call to hassession will
|
|
313
311
|
return a `401` with a `UserException` that says `No session found`.
|
|
314
312
|
|
|
315
|
-
##
|
|
313
|
+
## Publishing
|
|
316
314
|
|
|
317
|
-
|
|
315
|
+
Versioning and changelog are handled by [Release Please (GitHub Action)](https://github.com/googleapis/release-please). Publishing to [npmjs.org](https://www.npmjs.com/package/@schibsted/account-sdk-browser) is handled by the [npm-publish workflow](./.github/workflows/npm-publish.yml). See the [Release Please workflow](./.github/workflows/release-please.yml) and [`release-please-config.json`](./release-please-config.json).
|
|
318
316
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
317
|
+
When publishable changes have been merged to `master`, Release Please will create (or update) a release pull request.
|
|
318
|
+
The suggested version is based on the commit messages in accordance with the [Conventional Commits](https://www.conventionalcommits.org/) specification — `fix:` bumps the patch version, `feat:` bumps the minor version, and `feat!:` or a `BREAKING CHANGE:` footer bumps the major version.
|
|
319
|
+
Other prefixes (`chore:`, `docs:`, `test:`, `refactor:`, `ci:`, `build:`, `style:`) do not trigger a release and are hidden from the changelog.
|
|
320
|
+
|
|
321
|
+
To release/publish the changes simply merge the corresponding pull request and wait for the publish workflow to finish.
|
|
322
|
+
Release-please will create a git tag (e.g. `v5.2.7`) and a GitHub Release, and the [publish workflow](./.github/workflows/npm-publish.yml) will push the package to npmjs.org.
|
|
322
323
|
|
|
323
|
-
which will run the test, update version in package.json, commit, tag the commit
|
|
324
|
-
and push.
|
|
325
324
|
|
|
326
325
|
## LICENSE
|
|
327
326
|
|
|
328
|
-
Copyright (c)
|
|
327
|
+
Copyright (c) 2026 Schibsted Products & Technology AS
|
|
329
328
|
|
|
330
329
|
Licensed under the [MIT
|
|
331
|
-
License](https://
|
|
330
|
+
License](https://schibsted.ghe.com/user-identity/account-sdk-browser/blob/master/LICENSE.md)
|
|
332
331
|
|
|
333
332
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
334
333
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
package/es5/global.js
CHANGED
|
@@ -2490,6 +2490,11 @@ var Identity = /*#__PURE__*/function (_EventEmitter) {
|
|
|
2490
2490
|
_this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, {
|
|
2491
2491
|
error: _context.t0
|
|
2492
2492
|
}, expiresIn);
|
|
2493
|
+
} else if (_context.t0 && _context.t0.code >= 500 && _context.t0.code < 600 && _this2._enableSessionCaching) {
|
|
2494
|
+
// Temporary fix: 30 seconds cache to limit number of calls when service is unavailable
|
|
2495
|
+
_this2.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, {
|
|
2496
|
+
error: _context.t0
|
|
2497
|
+
}, 30 * 1000);
|
|
2493
2498
|
}
|
|
2494
2499
|
throw _context.t0;
|
|
2495
2500
|
case 15:
|
|
@@ -12199,11 +12204,11 @@ function emulate(global) {
|
|
|
12199
12204
|
|
|
12200
12205
|
"use strict";
|
|
12201
12206
|
__webpack_require__.r(__webpack_exports__);
|
|
12202
|
-
//
|
|
12207
|
+
// Version is bumped automatically by release-please. See release-please-config.json.
|
|
12203
12208
|
|
|
12204
12209
|
|
|
12205
12210
|
|
|
12206
|
-
var version = '5.2.
|
|
12211
|
+
var version = '5.2.7'; // x-release-please-version
|
|
12207
12212
|
/* harmony default export */ __webpack_exports__["default"] = (version);
|
|
12208
12213
|
|
|
12209
12214
|
/***/ }),
|
|
@@ -12277,31 +12282,37 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12277
12282
|
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_15__);
|
|
12278
12283
|
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(174);
|
|
12279
12284
|
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_16__);
|
|
12280
|
-
/* harmony import */ var
|
|
12281
|
-
/* harmony import */ var
|
|
12282
|
-
/* harmony import */ var
|
|
12283
|
-
/* harmony import */ var
|
|
12284
|
-
/* harmony import */ var
|
|
12285
|
-
/* harmony import */ var
|
|
12286
|
-
/* harmony import */ var
|
|
12287
|
-
/* harmony import */ var
|
|
12288
|
-
/* harmony import */ var
|
|
12289
|
-
/* harmony import */ var
|
|
12290
|
-
/* harmony import */ var
|
|
12291
|
-
/* harmony import */ var
|
|
12292
|
-
/* harmony import */ var
|
|
12293
|
-
/* harmony import */ var
|
|
12294
|
-
/* harmony import */ var
|
|
12295
|
-
/* harmony import */ var
|
|
12296
|
-
/* harmony import */ var
|
|
12297
|
-
/* harmony import */ var
|
|
12298
|
-
/* harmony import */ var
|
|
12299
|
-
/* harmony import */ var
|
|
12300
|
-
/* harmony import */ var
|
|
12301
|
-
/* harmony import */ var
|
|
12302
|
-
/* harmony import */ var
|
|
12303
|
-
/* harmony import */ var
|
|
12304
|
-
/* harmony import */ var
|
|
12285
|
+
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(76);
|
|
12286
|
+
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_17__);
|
|
12287
|
+
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(183);
|
|
12288
|
+
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_18__);
|
|
12289
|
+
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(149);
|
|
12290
|
+
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_19__);
|
|
12291
|
+
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(182);
|
|
12292
|
+
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_20__);
|
|
12293
|
+
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(201);
|
|
12294
|
+
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_21__);
|
|
12295
|
+
/* harmony import */ var core_js_modules_es_symbol_async_iterator_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(176);
|
|
12296
|
+
/* harmony import */ var core_js_modules_es_symbol_async_iterator_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_async_iterator_js__WEBPACK_IMPORTED_MODULE_22__);
|
|
12297
|
+
/* harmony import */ var core_js_modules_es_symbol_to_string_tag_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(177);
|
|
12298
|
+
/* harmony import */ var core_js_modules_es_symbol_to_string_tag_js__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_to_string_tag_js__WEBPACK_IMPORTED_MODULE_23__);
|
|
12299
|
+
/* harmony import */ var core_js_modules_es_json_to_string_tag_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(178);
|
|
12300
|
+
/* harmony import */ var core_js_modules_es_json_to_string_tag_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_json_to_string_tag_js__WEBPACK_IMPORTED_MODULE_24__);
|
|
12301
|
+
/* harmony import */ var core_js_modules_es_math_to_string_tag_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(179);
|
|
12302
|
+
/* harmony import */ var core_js_modules_es_math_to_string_tag_js__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_math_to_string_tag_js__WEBPACK_IMPORTED_MODULE_25__);
|
|
12303
|
+
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(180);
|
|
12304
|
+
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_26__);
|
|
12305
|
+
/* harmony import */ var _validate_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(184);
|
|
12306
|
+
/* harmony import */ var _url_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(204);
|
|
12307
|
+
/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(205);
|
|
12308
|
+
/* harmony import */ var tiny_emitter__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(206);
|
|
12309
|
+
/* harmony import */ var tiny_emitter__WEBPACK_IMPORTED_MODULE_30___default = /*#__PURE__*/__webpack_require__.n(tiny_emitter__WEBPACK_IMPORTED_MODULE_30__);
|
|
12310
|
+
/* harmony import */ var _RESTClient_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(215);
|
|
12311
|
+
/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(207);
|
|
12312
|
+
/* harmony import */ var _spidTalk_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(223);
|
|
12313
|
+
/* harmony import */ var _SDKError_js__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(190);
|
|
12314
|
+
/* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(224);
|
|
12315
|
+
/* harmony import */ var _global_registry_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(225);
|
|
12305
12316
|
/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
|
|
12306
12317
|
* See LICENSE.md in the project root.
|
|
12307
12318
|
*/
|
|
@@ -12310,6 +12321,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12310
12321
|
|
|
12311
12322
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12312
12323
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12324
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12325
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12326
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12327
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12328
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12329
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12313
12330
|
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); } }
|
|
12314
12331
|
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); }); }; }
|
|
12315
12332
|
|
|
@@ -12332,6 +12349,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
12332
12349
|
|
|
12333
12350
|
|
|
12334
12351
|
|
|
12352
|
+
|
|
12353
|
+
|
|
12354
|
+
|
|
12335
12355
|
|
|
12336
12356
|
|
|
12337
12357
|
|
|
@@ -12388,21 +12408,22 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12388
12408
|
window = _ref$window === void 0 ? globalWindow() : _ref$window;
|
|
12389
12409
|
_classCallCheck(this, Monetization);
|
|
12390
12410
|
_this = _super.call(this);
|
|
12391
|
-
|
|
12411
|
+
_spidTalk_js__WEBPACK_IMPORTED_MODULE_33__["emulate"](window);
|
|
12392
12412
|
// validate options
|
|
12393
|
-
Object(
|
|
12394
|
-
_this.cache = new
|
|
12413
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isNonEmptyString"])(clientId), 'clientId parameter is required');
|
|
12414
|
+
_this.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_32__["default"](function () {
|
|
12395
12415
|
return window && window.sessionStorage;
|
|
12396
12416
|
});
|
|
12397
12417
|
_this.clientId = clientId;
|
|
12398
12418
|
_this.env = env;
|
|
12399
12419
|
_this.redirectUri = redirectUri;
|
|
12420
|
+
_this.pendingHasAccessRequests = {};
|
|
12400
12421
|
_this._setSpidServerUrl(env);
|
|
12401
12422
|
if (sessionDomain) {
|
|
12402
|
-
Object(
|
|
12423
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isUrl"])(sessionDomain), 'sessionDomain parameter is not a valid URL');
|
|
12403
12424
|
_this._setSessionServiceUrl(sessionDomain);
|
|
12404
12425
|
}
|
|
12405
|
-
Object(
|
|
12426
|
+
Object(_global_registry_js__WEBPACK_IMPORTED_MODULE_36__["registerGlobal"])(window, 'Monetization', _assertThisInitialized(_this));
|
|
12406
12427
|
return _this;
|
|
12407
12428
|
}
|
|
12408
12429
|
|
|
@@ -12415,9 +12436,9 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12415
12436
|
_createClass(Monetization, [{
|
|
12416
12437
|
key: "_setSpidServerUrl",
|
|
12417
12438
|
value: function _setSpidServerUrl(url) {
|
|
12418
|
-
Object(
|
|
12419
|
-
this._spid = new
|
|
12420
|
-
serverUrl: Object(
|
|
12439
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isStr"])(url), "url parameter is invalid: ".concat(url));
|
|
12440
|
+
this._spid = new _RESTClient_js__WEBPACK_IMPORTED_MODULE_31__["default"]({
|
|
12441
|
+
serverUrl: Object(_url_js__WEBPACK_IMPORTED_MODULE_28__["urlMapper"])(url, _config_js__WEBPACK_IMPORTED_MODULE_29__["ENDPOINTS"].SPiD),
|
|
12421
12442
|
defaultParams: {
|
|
12422
12443
|
client_id: this.clientId,
|
|
12423
12444
|
redirect_uri: this.redirectUri
|
|
@@ -12434,15 +12455,15 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12434
12455
|
}, {
|
|
12435
12456
|
key: "_setSessionServiceUrl",
|
|
12436
12457
|
value: function _setSessionServiceUrl(domain) {
|
|
12437
|
-
Object(
|
|
12438
|
-
var client_sdrn = "sdrn:".concat(
|
|
12439
|
-
this._sessionService = new
|
|
12458
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isStr"])(domain), "domain parameter is invalid: ".concat(domain));
|
|
12459
|
+
var client_sdrn = "sdrn:".concat(_config_js__WEBPACK_IMPORTED_MODULE_29__["NAMESPACE"][this.env], ":client:").concat(this.clientId);
|
|
12460
|
+
this._sessionService = new _RESTClient_js__WEBPACK_IMPORTED_MODULE_31__["default"]({
|
|
12440
12461
|
serverUrl: domain,
|
|
12441
12462
|
log: this.log,
|
|
12442
12463
|
defaultParams: {
|
|
12443
12464
|
client_sdrn: client_sdrn,
|
|
12444
12465
|
redirect_uri: this.redirectUri,
|
|
12445
|
-
sdk_version:
|
|
12466
|
+
sdk_version: _version_js__WEBPACK_IMPORTED_MODULE_35__["default"]
|
|
12446
12467
|
}
|
|
12447
12468
|
});
|
|
12448
12469
|
}
|
|
@@ -12460,7 +12481,7 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12460
12481
|
key: "hasAccess",
|
|
12461
12482
|
value: function () {
|
|
12462
12483
|
var _hasAccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(productIds, userId) {
|
|
12463
|
-
var sortedIds, cacheKey, data, expiresSeconds;
|
|
12484
|
+
var sortedIds, cacheKey, data, promise, expiresSeconds;
|
|
12464
12485
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12465
12486
|
while (1) switch (_context.prev = _context.next) {
|
|
12466
12487
|
case 0:
|
|
@@ -12468,50 +12489,62 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12468
12489
|
_context.next = 2;
|
|
12469
12490
|
break;
|
|
12470
12491
|
}
|
|
12471
|
-
throw new
|
|
12492
|
+
throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_34__["default"]("hasAccess can only be called if 'sessionDomain' is configured");
|
|
12472
12493
|
case 2:
|
|
12473
12494
|
if (userId) {
|
|
12474
12495
|
_context.next = 4;
|
|
12475
12496
|
break;
|
|
12476
12497
|
}
|
|
12477
|
-
throw new
|
|
12498
|
+
throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_34__["default"]("'userId' must be specified");
|
|
12478
12499
|
case 4:
|
|
12479
12500
|
if (Array.isArray(productIds)) {
|
|
12480
12501
|
_context.next = 6;
|
|
12481
12502
|
break;
|
|
12482
12503
|
}
|
|
12483
|
-
throw new
|
|
12504
|
+
throw new _SDKError_js__WEBPACK_IMPORTED_MODULE_34__["default"]("'productIds' must be an array");
|
|
12484
12505
|
case 6:
|
|
12485
|
-
sortedIds = productIds.sort();
|
|
12486
|
-
cacheKey = this._accessCacheKey(
|
|
12506
|
+
sortedIds = _toConsumableArray(productIds).sort();
|
|
12507
|
+
cacheKey = this._accessCacheKey(sortedIds, userId);
|
|
12487
12508
|
data = this.cache.get(cacheKey);
|
|
12488
12509
|
if (data) {
|
|
12489
|
-
_context.next =
|
|
12510
|
+
_context.next = 21;
|
|
12490
12511
|
break;
|
|
12491
12512
|
}
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12513
|
+
if (!this.pendingHasAccessRequests[cacheKey]) {
|
|
12514
|
+
this.pendingHasAccessRequests[cacheKey] = this._sessionService.get("/hasAccess/".concat(sortedIds.join(',')));
|
|
12515
|
+
}
|
|
12516
|
+
promise = this.pendingHasAccessRequests[cacheKey];
|
|
12517
|
+
_context.prev = 12;
|
|
12518
|
+
_context.next = 15;
|
|
12519
|
+
return promise;
|
|
12520
|
+
case 15:
|
|
12495
12521
|
data = _context.sent;
|
|
12496
12522
|
expiresSeconds = data.ttl;
|
|
12497
12523
|
this.cache.set(cacheKey, data, expiresSeconds * 1000);
|
|
12498
|
-
case
|
|
12524
|
+
case 18:
|
|
12525
|
+
_context.prev = 18;
|
|
12526
|
+
// If it rejects, we still want to clear the pending request
|
|
12527
|
+
if (this.pendingHasAccessRequests[cacheKey] === promise) {
|
|
12528
|
+
delete this.pendingHasAccessRequests[cacheKey];
|
|
12529
|
+
}
|
|
12530
|
+
return _context.finish(18);
|
|
12531
|
+
case 21:
|
|
12499
12532
|
if (data.entitled) {
|
|
12500
|
-
_context.next =
|
|
12533
|
+
_context.next = 23;
|
|
12501
12534
|
break;
|
|
12502
12535
|
}
|
|
12503
12536
|
return _context.abrupt("return", null);
|
|
12504
|
-
case
|
|
12537
|
+
case 23:
|
|
12505
12538
|
this.emit('hasAccess', {
|
|
12506
12539
|
ids: sortedIds,
|
|
12507
12540
|
data: data
|
|
12508
12541
|
});
|
|
12509
12542
|
return _context.abrupt("return", data);
|
|
12510
|
-
case
|
|
12543
|
+
case 25:
|
|
12511
12544
|
case "end":
|
|
12512
12545
|
return _context.stop();
|
|
12513
12546
|
}
|
|
12514
|
-
}, _callee, this);
|
|
12547
|
+
}, _callee, this, [[12,, 18, 21]]);
|
|
12515
12548
|
}));
|
|
12516
12549
|
function hasAccess(_x, _x2) {
|
|
12517
12550
|
return _hasAccess.apply(this, arguments);
|
|
@@ -12540,7 +12573,7 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12540
12573
|
}, {
|
|
12541
12574
|
key: "_accessCacheKey",
|
|
12542
12575
|
value: function _accessCacheKey(productIds, userId) {
|
|
12543
|
-
return "prd_".concat(productIds.sort(), "_").concat(userId);
|
|
12576
|
+
return "prd_".concat(_toConsumableArray(productIds).sort(), "_").concat(userId);
|
|
12544
12577
|
}
|
|
12545
12578
|
|
|
12546
12579
|
/**
|
|
@@ -12552,7 +12585,7 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12552
12585
|
key: "subscriptionsUrl",
|
|
12553
12586
|
value: function subscriptionsUrl() {
|
|
12554
12587
|
var redirectUri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.redirectUri;
|
|
12555
|
-
Object(
|
|
12588
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isUrl"])(redirectUri), "subscriptionsUrl(): redirectUri is invalid");
|
|
12556
12589
|
return this._spid.makeUrl('account/subscriptions', {
|
|
12557
12590
|
redirect_uri: redirectUri
|
|
12558
12591
|
});
|
|
@@ -12567,14 +12600,14 @@ var Monetization = /*#__PURE__*/function (_EventEmitter) {
|
|
|
12567
12600
|
key: "productsUrl",
|
|
12568
12601
|
value: function productsUrl() {
|
|
12569
12602
|
var redirectUri = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.redirectUri;
|
|
12570
|
-
Object(
|
|
12603
|
+
Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["assert"])(Object(_validate_js__WEBPACK_IMPORTED_MODULE_27__["isUrl"])(redirectUri), "productsUrl(): redirectUri is invalid");
|
|
12571
12604
|
return this._spid.makeUrl('account/products', {
|
|
12572
12605
|
redirect_uri: redirectUri
|
|
12573
12606
|
});
|
|
12574
12607
|
}
|
|
12575
12608
|
}]);
|
|
12576
12609
|
return Monetization;
|
|
12577
|
-
}(
|
|
12610
|
+
}(tiny_emitter__WEBPACK_IMPORTED_MODULE_30___default.a);
|
|
12578
12611
|
/* harmony default export */ __webpack_exports__["default"] = (Monetization);
|
|
12579
12612
|
|
|
12580
12613
|
/***/ }),
|
|
@@ -12835,7 +12868,7 @@ var Payment = /*#__PURE__*/function () {
|
|
|
12835
12868
|
}
|
|
12836
12869
|
|
|
12837
12870
|
/**
|
|
12838
|
-
* @deprecated https://
|
|
12871
|
+
* @deprecated https://schibsted.ghe.com/user-identity/account-sdk-browser/issues/94
|
|
12839
12872
|
*
|
|
12840
12873
|
* Get the url for the paylink purchase
|
|
12841
12874
|
* @todo Check working-ness for BFF + SPiD
|