@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.
- package/README.md +46 -301
- package/dist/account-sdk.d.ts +22 -0
- package/dist/account.d.ts +179 -0
- package/dist/cache.d.ts +65 -0
- package/dist/config.d.ts +86 -0
- package/dist/globals.d.ts +11 -0
- package/dist/has-access-response.d.ts +2 -0
- package/dist/identity.d.ts +302 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +828 -0
- package/dist/index.js.map +1 -0
- package/dist/monetization.d.ts +39 -0
- package/{src → dist}/object.d.ts +4 -9
- package/dist/popup.d.ts +9 -0
- package/dist/resolve-browser-window.d.ts +1 -0
- package/dist/rest-client.d.ts +102 -0
- package/dist/rest-clients.d.ts +10 -0
- package/dist/sdk-error.d.ts +29 -0
- package/dist/session-response.d.ts +54 -0
- package/{src/spidTalk.d.ts → dist/spid-talk.d.ts} +4 -6
- package/dist/types/account.d.ts +48 -0
- package/dist/types/common.d.ts +28 -0
- package/dist/types/identity.d.ts +23 -0
- package/dist/types/login.d.ts +125 -0
- package/dist/types/monetization.d.ts +26 -0
- package/dist/types/session.d.ts +146 -0
- package/dist/url.d.ts +8 -0
- package/dist/validate.d.ts +50 -0
- package/dist/version.d.ts +2 -0
- package/package.json +34 -52
- package/src/account-sdk.ts +92 -0
- package/src/account.ts +332 -0
- package/src/{cache.js → cache.ts} +53 -38
- package/src/{config.js → config.ts} +7 -32
- package/src/globals.ts +8 -0
- package/src/has-access-response.ts +35 -0
- package/src/identity.ts +1023 -0
- package/src/index.ts +40 -0
- package/src/monetization.ts +128 -0
- package/src/{object.js → object.ts} +9 -16
- package/src/popup.ts +74 -0
- package/src/resolve-browser-window.ts +11 -0
- package/src/rest-client.ts +253 -0
- package/src/rest-clients.ts +30 -0
- package/src/sdk-error.ts +61 -0
- package/src/session-response.ts +100 -0
- package/src/{spidTalk.js → spid-talk.ts} +10 -12
- package/src/types/account.ts +55 -0
- package/src/types/common.ts +32 -0
- package/src/types/identity.ts +26 -0
- package/src/types/login.ts +150 -0
- package/src/types/monetization.ts +29 -0
- package/src/types/session.ts +169 -0
- package/src/{url.js → url.ts} +6 -10
- package/src/{validate.js → validate.ts} +27 -43
- package/src/{version.js → version.ts} +1 -2
- package/es5/global.js +0 -12968
- package/es5/global.js.map +0 -1
- package/es5/global.min.js +0 -2
- package/es5/global.min.js.map +0 -1
- package/es5/identity.js +0 -12212
- package/es5/identity.js.map +0 -1
- package/es5/identity.min.js +0 -2
- package/es5/identity.min.js.map +0 -1
- package/es5/index.js +0 -12940
- package/es5/index.js.map +0 -1
- package/es5/index.min.js +0 -2
- package/es5/index.min.js.map +0 -1
- package/es5/monetization.js +0 -9176
- package/es5/monetization.js.map +0 -1
- package/es5/monetization.min.js +0 -2
- package/es5/monetization.min.js.map +0 -1
- package/es5/payment.js +0 -8853
- package/es5/payment.js.map +0 -1
- package/es5/payment.min.js +0 -2
- package/es5/payment.min.js.map +0 -1
- package/identity.d.ts +0 -1
- package/identity.js +0 -5
- package/index.d.ts +0 -4
- package/index.js +0 -9
- package/monetization.d.ts +0 -1
- package/monetization.js +0 -5
- package/payment.d.ts +0 -1
- package/payment.js +0 -5
- package/src/RESTClient.d.ts +0 -89
- package/src/RESTClient.js +0 -193
- package/src/SDKError.d.ts +0 -16
- package/src/SDKError.js +0 -55
- package/src/__mocks__/.eslintrc.yml +0 -8
- package/src/__mocks__/RESTClient.js +0 -54
- package/src/cache.d.ts +0 -64
- package/src/config.d.ts +0 -34
- package/src/es5/global.js +0 -13
- package/src/es5/identity.js +0 -10
- package/src/es5/index.js +0 -13
- package/src/es5/monetization.js +0 -10
- package/src/es5/payment.js +0 -10
- package/src/global-registry.js +0 -20
- package/src/identity.d.ts +0 -679
- package/src/identity.js +0 -1157
- package/src/monetization.d.ts +0 -80
- package/src/monetization.js +0 -172
- package/src/payment.d.ts +0 -115
- package/src/payment.js +0 -211
- package/src/popup.d.ts +0 -10
- package/src/popup.js +0 -59
- package/src/url.d.ts +0 -10
- package/src/validate.d.ts +0 -64
- 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
|
-
|
|
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
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
74
|
-
* @param
|
|
75
|
-
*
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
101
|
-
* @param
|
|
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
|
|
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;
|