@schibsted/account-sdk-browser 5.2.7 → 6.0.0-alpha.10

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.
Files changed (109) hide show
  1. package/README.md +46 -301
  2. package/dist/account-sdk.d.ts +22 -0
  3. package/dist/account.d.ts +179 -0
  4. package/dist/cache.d.ts +65 -0
  5. package/dist/config.d.ts +86 -0
  6. package/dist/globals.d.ts +11 -0
  7. package/dist/has-access-response.d.ts +2 -0
  8. package/dist/identity.d.ts +302 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +828 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/monetization.d.ts +39 -0
  13. package/{src → dist}/object.d.ts +4 -9
  14. package/dist/popup.d.ts +9 -0
  15. package/dist/resolve-browser-window.d.ts +1 -0
  16. package/dist/rest-client.d.ts +102 -0
  17. package/dist/rest-clients.d.ts +10 -0
  18. package/dist/sdk-error.d.ts +29 -0
  19. package/dist/session-response.d.ts +54 -0
  20. package/{src/spidTalk.d.ts → dist/spid-talk.d.ts} +4 -6
  21. package/dist/types/account.d.ts +48 -0
  22. package/dist/types/common.d.ts +28 -0
  23. package/dist/types/identity.d.ts +23 -0
  24. package/dist/types/login.d.ts +125 -0
  25. package/dist/types/monetization.d.ts +26 -0
  26. package/dist/types/session.d.ts +146 -0
  27. package/dist/url.d.ts +8 -0
  28. package/dist/validate.d.ts +50 -0
  29. package/dist/version.d.ts +2 -0
  30. package/package.json +34 -52
  31. package/src/account-sdk.ts +92 -0
  32. package/src/account.ts +332 -0
  33. package/src/{cache.js → cache.ts} +53 -38
  34. package/src/{config.js → config.ts} +7 -32
  35. package/src/globals.ts +8 -0
  36. package/src/has-access-response.ts +35 -0
  37. package/src/identity.ts +1023 -0
  38. package/src/index.ts +40 -0
  39. package/src/monetization.ts +128 -0
  40. package/src/{object.js → object.ts} +9 -16
  41. package/src/popup.ts +74 -0
  42. package/src/resolve-browser-window.ts +11 -0
  43. package/src/rest-client.ts +253 -0
  44. package/src/rest-clients.ts +30 -0
  45. package/src/sdk-error.ts +61 -0
  46. package/src/session-response.ts +100 -0
  47. package/src/{spidTalk.js → spid-talk.ts} +10 -12
  48. package/src/types/account.ts +55 -0
  49. package/src/types/common.ts +32 -0
  50. package/src/types/identity.ts +26 -0
  51. package/src/types/login.ts +150 -0
  52. package/src/types/monetization.ts +29 -0
  53. package/src/types/session.ts +169 -0
  54. package/src/{url.js → url.ts} +6 -10
  55. package/src/{validate.js → validate.ts} +27 -43
  56. package/src/{version.js → version.ts} +1 -2
  57. package/es5/global.js +0 -12968
  58. package/es5/global.js.map +0 -1
  59. package/es5/global.min.js +0 -2
  60. package/es5/global.min.js.map +0 -1
  61. package/es5/identity.js +0 -12212
  62. package/es5/identity.js.map +0 -1
  63. package/es5/identity.min.js +0 -2
  64. package/es5/identity.min.js.map +0 -1
  65. package/es5/index.js +0 -12940
  66. package/es5/index.js.map +0 -1
  67. package/es5/index.min.js +0 -2
  68. package/es5/index.min.js.map +0 -1
  69. package/es5/monetization.js +0 -9176
  70. package/es5/monetization.js.map +0 -1
  71. package/es5/monetization.min.js +0 -2
  72. package/es5/monetization.min.js.map +0 -1
  73. package/es5/payment.js +0 -8853
  74. package/es5/payment.js.map +0 -1
  75. package/es5/payment.min.js +0 -2
  76. package/es5/payment.min.js.map +0 -1
  77. package/identity.d.ts +0 -1
  78. package/identity.js +0 -5
  79. package/index.d.ts +0 -4
  80. package/index.js +0 -9
  81. package/monetization.d.ts +0 -1
  82. package/monetization.js +0 -5
  83. package/payment.d.ts +0 -1
  84. package/payment.js +0 -5
  85. package/src/RESTClient.d.ts +0 -89
  86. package/src/RESTClient.js +0 -193
  87. package/src/SDKError.d.ts +0 -16
  88. package/src/SDKError.js +0 -55
  89. package/src/__mocks__/.eslintrc.yml +0 -8
  90. package/src/__mocks__/RESTClient.js +0 -54
  91. package/src/cache.d.ts +0 -64
  92. package/src/config.d.ts +0 -34
  93. package/src/es5/global.js +0 -13
  94. package/src/es5/identity.js +0 -10
  95. package/src/es5/index.js +0 -13
  96. package/src/es5/monetization.js +0 -10
  97. package/src/es5/payment.js +0 -10
  98. package/src/global-registry.js +0 -20
  99. package/src/identity.d.ts +0 -679
  100. package/src/identity.js +0 -1157
  101. package/src/monetization.d.ts +0 -80
  102. package/src/monetization.js +0 -172
  103. package/src/payment.d.ts +0 -115
  104. package/src/payment.js +0 -211
  105. package/src/popup.d.ts +0 -10
  106. package/src/popup.js +0 -59
  107. package/src/url.d.ts +0 -10
  108. package/src/validate.d.ts +0 -64
  109. package/src/version.d.ts +0 -2
@@ -2,9 +2,7 @@
2
2
  * See LICENSE.md in the project root.
3
3
  */
4
4
 
5
- 'use strict';
6
-
7
- import SDKError from './SDKError.js';
5
+ import SDKError from './sdk-error.js';
8
6
 
9
7
  /*
10
8
  * This module defines a set of validation functions which are used in the rest of the SDK.
@@ -16,13 +14,13 @@ import SDKError from './SDKError.js';
16
14
  /**
17
15
  * A utility function that throws an SDKError if an assertion fails. It's mostly useful for
18
16
  * validating function inputs.
19
- * @memberof core
20
- * @param {boolean} condition - The condition that we're asserting
21
- * @param {string} [message = Assertion failed] - The error message
17
+ *
18
+ * Narrows `condition` for the rest of the enclosing scope (TypeScript assertion signature).
19
+ * @param condition - The condition that we're asserting
20
+ * @param message - The error message
22
21
  * @throws {SDKError} - If the condition is falsy it throws the appropriate error
23
- * @return {void}
24
22
  */
25
- export function assert(condition, message = 'Assertion failed') {
23
+ export function assert(condition: boolean, message = 'Assertion failed'): asserts condition {
26
24
  if (!condition) {
27
25
  throw new SDKError(message);
28
26
  }
@@ -30,82 +28,68 @@ export function assert(condition, message = 'Assertion failed') {
30
28
 
31
29
  /**
32
30
  * Checks if a value is a string or not
33
- * @memberof core
34
- * @param {*} value - The value to check
35
- * @return {boolean}
31
+ * @param value - The value to check
36
32
  */
37
- export function isStr(value) {
33
+ export function isStr(value: unknown): value is string {
38
34
  return typeof value === 'string';
39
35
  }
40
36
 
41
37
  /**
42
38
  * Checks if a value is a non-empty string
43
- * @memberof core
44
- * @param {*} value - The value to check
45
- * @return {boolean}
39
+ * @param value - The value to check
46
40
  */
47
- export function isNonEmptyString(value) {
41
+ export function isNonEmptyString(value: unknown): value is string {
48
42
  return typeof value === 'string' && value.length > 0;
49
43
  }
50
44
 
51
45
  /**
52
46
  * checks if a given value is an object (but not null)
53
- * @memberof core
54
- * @param {*} value - The value to check
55
- * @return {boolean}
47
+ * @param value - The value to check
56
48
  */
57
- export function isObject(value) {
49
+ export function isObject(value: unknown): value is Record<string, unknown> {
58
50
  return typeof value === 'object' && value !== null;
59
51
  }
60
52
 
61
53
  /**
62
54
  * Checks if a given value is an object with at least one own key
63
- * @memberof core
64
- * @param {*} value - The value to check
65
- * @return {boolean}
55
+ * @param value - The value to check
66
56
  */
67
- export function isNonEmptyObj(value) {
57
+ export function isNonEmptyObj(value: unknown): value is Record<string, unknown> {
68
58
  return isObject(value) && Object.keys(value).length > 0;
69
59
  }
70
60
 
71
61
  /**
72
62
  * Checks if a given string is a valid URL
73
- * @memberof core
74
- * @param {string} value - The string to be tested
75
- * @param {...string} mandatoryFields - A list of mandatory fields that should exist in the parsed
76
- * URL object
77
- * @return {boolean}
63
+ * @param value - The string to be tested
64
+ * @param mandatoryFields - A list of mandatory fields that should exist in the parsed
65
+ * `URL` object
78
66
  */
79
- export function isUrl(value, ...mandatoryFields) {
67
+ export function isUrl(value: string, ...mandatoryFields: (keyof URL)[]): boolean {
80
68
  try {
81
69
  const parsedUrl = new URL(value);
82
- return mandatoryFields.every(f => parsedUrl[f]);
83
- } catch (urlParsingError) {
70
+ return mandatoryFields.every((f) => parsedUrl[f]);
71
+ } catch {
84
72
  return false;
85
73
  }
86
74
  }
87
75
 
88
76
  /**
89
77
  * Checks if a given value is a function
90
- * @memberof core
91
- * @param {*} value - The value to check
92
- * @return {boolean}
78
+ * @param value - The value to check
93
79
  */
94
- export function isFunction(value) {
80
+ export function isFunction(value: unknown): value is (...args: unknown[]) => unknown {
95
81
  return typeof value === 'function';
96
82
  }
97
83
 
98
84
  /**
99
85
  * Checks if a string matches any of the strings in a set of possibilities
100
- * @memberof core
101
- * @param {string} value
102
- * @param {string[]} possibilities - An array of strings that'll be used to check the string
86
+ * @param value
87
+ * @param possibilities - An array of strings that'll be used to check the string
103
88
  * inclusion. Note that for performance reasons, we don't validate this parameter.
104
- * @param {boolean} [caseSensitive=false] - Should the check be case sensitive
105
- * @return {boolean}
89
+ * @param caseSensitive - Should the check be case sensitive
106
90
  */
107
- export function isStrIn(value, possibilities, caseSensitive = false) {
108
- const _isSameStrCaseInsensitive = str =>
91
+ export function isStrIn(value: string, possibilities: string[], caseSensitive = false): boolean {
92
+ const _isSameStrCaseInsensitive = (str: string) =>
109
93
  isStr(str) && value.toUpperCase() === str.toUpperCase();
110
94
  if (!(isStr(value) && Array.isArray(possibilities))) {
111
95
  return false;
@@ -1,5 +1,4 @@
1
1
  // Version is bumped automatically by release-please. See release-please-config.json.
2
2
 
3
- 'use strict'
4
- const version = '5.2.7'; // x-release-please-version
3
+ const version = '6.0.0-alpha.10'; // x-release-please-version
5
4
  export default version;