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

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 (90) hide show
  1. package/README.md +12 -59
  2. package/dist/RESTClient.d.ts +91 -0
  3. package/dist/SDKError.d.ts +27 -0
  4. package/dist/cache.d.ts +65 -0
  5. package/dist/config.d.ts +86 -0
  6. package/dist/global-registry.d.ts +23 -0
  7. package/dist/globals.d.ts +13 -0
  8. package/dist/identity-s4nofYmB.js +370 -0
  9. package/dist/identity-s4nofYmB.js.map +1 -0
  10. package/dist/identity.d.ts +523 -0
  11. package/dist/identity.js +2 -0
  12. package/dist/index.d.ts +3 -0
  13. package/dist/index.js +4 -0
  14. package/dist/monetization.d.ts +94 -0
  15. package/dist/monetization.js +72 -0
  16. package/dist/monetization.js.map +1 -0
  17. package/{src → dist}/object.d.ts +4 -9
  18. package/dist/popup.d.ts +9 -0
  19. package/{src → dist}/spidTalk.d.ts +4 -6
  20. package/dist/url.d.ts +8 -0
  21. package/dist/validate.d.ts +50 -0
  22. package/dist/version-spE-k97g.js +289 -0
  23. package/dist/version-spE-k97g.js.map +1 -0
  24. package/dist/version.d.ts +2 -0
  25. package/package.json +42 -49
  26. package/src/RESTClient.ts +226 -0
  27. package/src/SDKError.ts +59 -0
  28. package/src/{cache.js → cache.ts} +52 -37
  29. package/src/{config.js → config.ts} +7 -32
  30. package/src/global-registry.ts +39 -0
  31. package/src/globals.ts +10 -0
  32. package/src/{identity.js → identity.ts} +536 -437
  33. package/{index.js → src/index.ts} +1 -3
  34. package/src/{monetization.js → monetization.ts} +77 -48
  35. package/src/{object.js → object.ts} +8 -15
  36. package/src/popup.ts +74 -0
  37. package/src/{spidTalk.js → spidTalk.ts} +10 -12
  38. package/src/{url.js → url.ts} +6 -10
  39. package/src/{validate.js → validate.ts} +26 -42
  40. package/src/{version.js → version.ts} +1 -2
  41. package/es5/global.js +0 -12968
  42. package/es5/global.js.map +0 -1
  43. package/es5/global.min.js +0 -2
  44. package/es5/global.min.js.map +0 -1
  45. package/es5/identity.js +0 -12212
  46. package/es5/identity.js.map +0 -1
  47. package/es5/identity.min.js +0 -2
  48. package/es5/identity.min.js.map +0 -1
  49. package/es5/index.js +0 -12940
  50. package/es5/index.js.map +0 -1
  51. package/es5/index.min.js +0 -2
  52. package/es5/index.min.js.map +0 -1
  53. package/es5/monetization.js +0 -9176
  54. package/es5/monetization.js.map +0 -1
  55. package/es5/monetization.min.js +0 -2
  56. package/es5/monetization.min.js.map +0 -1
  57. package/es5/payment.js +0 -8853
  58. package/es5/payment.js.map +0 -1
  59. package/es5/payment.min.js +0 -2
  60. package/es5/payment.min.js.map +0 -1
  61. package/identity.d.ts +0 -1
  62. package/identity.js +0 -5
  63. package/index.d.ts +0 -4
  64. package/monetization.d.ts +0 -1
  65. package/monetization.js +0 -5
  66. package/payment.d.ts +0 -1
  67. package/payment.js +0 -5
  68. package/src/RESTClient.d.ts +0 -89
  69. package/src/RESTClient.js +0 -193
  70. package/src/SDKError.d.ts +0 -16
  71. package/src/SDKError.js +0 -55
  72. package/src/__mocks__/.eslintrc.yml +0 -8
  73. package/src/__mocks__/RESTClient.js +0 -54
  74. package/src/cache.d.ts +0 -64
  75. package/src/config.d.ts +0 -34
  76. package/src/es5/global.js +0 -13
  77. package/src/es5/identity.js +0 -10
  78. package/src/es5/index.js +0 -13
  79. package/src/es5/monetization.js +0 -10
  80. package/src/es5/payment.js +0 -10
  81. package/src/global-registry.js +0 -20
  82. package/src/identity.d.ts +0 -679
  83. package/src/monetization.d.ts +0 -80
  84. package/src/payment.d.ts +0 -115
  85. package/src/payment.js +0 -211
  86. package/src/popup.d.ts +0 -10
  87. package/src/popup.js +0 -59
  88. package/src/url.d.ts +0 -10
  89. package/src/validate.d.ts +0 -64
  90. package/src/version.d.ts +0 -2
@@ -1,80 +0,0 @@
1
- /**
2
- * Provides features related to monetization
3
- */
4
- export class Monetization {
5
- /**
6
- * @param {object} options
7
- * @param {string} options.clientId - Mandatory client id
8
- * @param {string} options.redirectUri - Redirect uri
9
- * @param {string} options.sessionDomain - Example: "https://id.site.com"
10
- * @param {string} [options.env=PRE] - Schibsted account environment: `PRE`, `PRO` or `PRO_NO`
11
- * @param {object} [options.window]
12
- * @throws {SDKError} - If any of options are invalid
13
- */
14
- constructor({ clientId, redirectUri, env, sessionDomain, window }: {
15
- clientId: string;
16
- redirectUri: string;
17
- sessionDomain: string;
18
- env?: string;
19
- window?: any;
20
- });
21
- cache: any;
22
- clientId: string;
23
- env: string;
24
- redirectUri: string;
25
- /**
26
- * Set SPiD server URL
27
- * @private
28
- * @param {string} url
29
- * @returns {void}
30
- */
31
- private _setSpidServerUrl;
32
- _spid: RESTClient;
33
- /**
34
- * Set session-service domain
35
- * @private
36
- * @param {string} domain - real URL — (**not** 'PRE' style env key)
37
- * @returns {void}
38
- */
39
- private _setSessionServiceUrl;
40
- _sessionService: RESTClient;
41
- /**
42
- * Checks if the user has access to a set of products or features.
43
- * @param {array} productIds - which products/features to check
44
- * @param {number} userId - id of currently logged in user
45
- * @throws {SDKError} - If the input is incorrect, or a network call fails in any way
46
- * (this will happen if, say, the user is not logged in)
47
- * @returns {Object|null} The data object returned from Schibsted account (or `null` if the user
48
- * doesn't have access to any of the given products/features)
49
- */
50
- hasAccess(productIds: any[], userId: number): any;
51
- /**
52
- * Removes the cached access result.
53
- * @param {array} productIds - which products/features to check
54
- * @param {number} userId - id of currently logged in user
55
- * @returns {void}
56
- */
57
- clearCachedAccessResult(productIds: any[], userId: number): void;
58
- /**
59
- * Compute "has access" cache key for the given product ids and user id.
60
- * @param {array} productIds - which products/features to check
61
- * @param {number} userId - id of currently logged in user
62
- * @returns {string}
63
- * @private
64
- */
65
- private _accessCacheKey;
66
- /**
67
- * Get the url for the end user to review the subscriptions
68
- * @param {string} [redirectUri=this.redirectUri]
69
- * @return {string} - The url to the subscriptions review page
70
- */
71
- subscriptionsUrl(redirectUri?: string): string;
72
- /**
73
- * Get the url for the end user to review the products
74
- * @param {string} [redirectUri=this.redirectUri]
75
- * @return {string} - The url to the products review page
76
- */
77
- productsUrl(redirectUri?: string): string;
78
- }
79
- export default Monetization;
80
- import RESTClient from "./RESTClient.js";
package/src/payment.d.ts DELETED
@@ -1,115 +0,0 @@
1
- /**
2
- * Provides features related to payment
3
- */
4
- export class Payment {
5
- /**
6
- * @param {object} options
7
- * @param {string} options.clientId - Mandatory client id
8
- * @param {string} [options.redirectUri] - Redirect uri
9
- * @param {string} [options.env=PRE] - Schibsted account environment: `PRE`, `PRO` or `PRO_NO`
10
- * @param {string} [options.publisher] - ZUORA publisher
11
- * @param {object} [options.window]
12
- *
13
- * @throws {SDKError} - If any of options are invalid
14
- */
15
- constructor({ clientId, redirectUri, env, publisher, window }: {
16
- clientId: string;
17
- redirectUri?: string;
18
- env?: string;
19
- publisher?: string;
20
- window?: any;
21
- });
22
- clientId: string;
23
- redirectUri: string;
24
- window: any;
25
- publisher: string;
26
- /**
27
- * Set SPiD server URL
28
- * @private
29
- * @param {string} url - real URL or 'PRE' style key
30
- * @returns {void}
31
- */
32
- private _setSpidServerUrl;
33
- _spid: RESTClient;
34
- /**
35
- * Set BFF server URL - real URL or 'PRE' style key
36
- * @private
37
- * @param {string} url
38
- * @returns {void}
39
- */
40
- private _setBffServerUrl;
41
- _bff: RESTClient;
42
- /**
43
- * Close this.popup if it exists and is open
44
- * @private
45
- * @returns {void}
46
- */
47
- private _closePopup;
48
- popup: Window;
49
- /**
50
- * Starts the flow for the paylink in a popup or current window
51
- * @param {object} options
52
- * @param {string} options.paylink - The paylink
53
- * @param {boolean} [options.preferPopup=false] - Should we try to open a popup?
54
- * @param {string} [options.redirectUri=this.redirectUri]
55
- * @returns {Window|null} - Returns a reference to the popup window, or `null` if no popup was
56
- * used
57
- */
58
- payWithPaylink({ paylink, preferPopup, redirectUri }: {
59
- paylink: string;
60
- preferPopup?: boolean;
61
- redirectUri?: string;
62
- }): Window;
63
- /**
64
- * Get the url for the end user to review the purchase history
65
- * @param {string} [redirectUri=this.redirectUri]
66
- * @return {string} - The url to the purchase history review page
67
- */
68
- purchaseHistoryUrl(redirectUri?: string): string;
69
- /**
70
- * Get the url for the end user to redeem a voucher code
71
- * @param {string} voucherCode
72
- * @param {string} [redirectUri=this.redirectUri]
73
- * @return {string} - The url
74
- */
75
- redeemUrl(voucherCode: string, redirectUri?: string): string;
76
- /**
77
- * @deprecated https://schibsted.ghe.com/user-identity/account-sdk-browser/issues/94
78
- *
79
- * Get the url for the paylink purchase
80
- * @todo Check working-ness for BFF + SPiD
81
- * @param {string} paylinkId
82
- * @param {string} [redirectUri=this.redirectUri]
83
- * @return {string} - The url to the API endpoint
84
- */
85
- purchasePaylinkUrl(paylinkId: string, redirectUri?: string): string;
86
- /**
87
- * Get the url for flow to purchase a product
88
- * @param {string} productId
89
- * @param {string} [redirectUri=this.redirectUri]
90
- * @return {string} - The url to the products review page
91
- */
92
- purchaseProductFlowUrl(productId: string, redirectUri?: string): string;
93
- /**
94
- * Get the url for flow to purchase a product through a campaign and voucher code
95
- * @todo Check working-ness for BFF + SPiD
96
- * @param {string} campaignId
97
- * @param {string} productId
98
- * @param {string} [voucherCode]
99
- * @param {string} [redirectUri=this.redirectUri]
100
- * @return {string} - The url to the products review page
101
- */
102
- purchaseCampaignFlowUrl(campaignId: string, productId: string, voucherCode?: string, redirectUri?: string): string;
103
- /**
104
- * @deprecated
105
- * Get the url for flow to purchase a promo code product with ZUORA
106
- * @param {string} code - promocode product code
107
- * @param {string} [state=''] - An opaque value used by the client to maintain state between
108
- * the request and callback. It's also recommended to prevent CSRF
109
- * @param {string} [redirectUri=this.redirectUri]
110
- * @return {string} - The url to the buy promo code product flow
111
- */
112
- purchasePromoCodeProductFlowUrl(code: string, state?: string, redirectUri?: string): string;
113
- }
114
- export default Payment;
115
- import RESTClient from "./RESTClient.js";
package/src/payment.js DELETED
@@ -1,211 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- import { assert, isNonEmptyString, isUrl, isStr } from './validate.js';
8
- import { urlMapper } from './url.js';
9
- import { ENDPOINTS } from './config.js';
10
- import * as popup from './popup.js';
11
- import RESTClient from './RESTClient.js';
12
- import * as spidTalk from './spidTalk.js';
13
- import { registerGlobal } from './global-registry.js';
14
-
15
- const globalWindow = () => window;
16
-
17
- /**
18
- * Provides features related to payment
19
- */
20
- export class Payment {
21
- /**
22
- * @param {object} options
23
- * @param {string} options.clientId - Mandatory client id
24
- * @param {string} [options.redirectUri] - Redirect uri
25
- * @param {string} [options.env=PRE] - Schibsted account environment: `PRE`, `PRO` or `PRO_NO`
26
- * @param {string} [options.publisher] - ZUORA publisher
27
- * @param {object} [options.window]
28
- *
29
- * @throws {SDKError} - If any of options are invalid
30
- */
31
- constructor({ clientId, redirectUri, env = 'PRE', publisher, window = globalWindow() }) {
32
- spidTalk.emulate(window);
33
- assert(isNonEmptyString(clientId), 'clientId parameter is required');
34
-
35
- this.clientId = clientId;
36
- this.redirectUri = redirectUri;
37
- this.window = window;
38
- this.publisher = publisher;
39
- this._setSpidServerUrl(env);
40
- this._setBffServerUrl(env);
41
- registerGlobal(window, 'Payment', this);
42
- }
43
-
44
- /**
45
- * Set SPiD server URL
46
- * @private
47
- * @param {string} url - real URL or 'PRE' style key
48
- * @returns {void}
49
- */
50
- _setSpidServerUrl(url) {
51
- assert(isStr(url), `url parameter is invalid: ${url}`);
52
- this._spid = new RESTClient({
53
- serverUrl: urlMapper(url, ENDPOINTS.SPiD),
54
- defaultParams: { client_id: this.clientId, redirect_uri: this.redirectUri },
55
- });
56
- }
57
-
58
- /**
59
- * Set BFF server URL - real URL or 'PRE' style key
60
- * @private
61
- * @param {string} url
62
- * @returns {void}
63
- */
64
- _setBffServerUrl(url) {
65
- assert(isStr(url), `url parameter is invalid: ${url}`);
66
- this._bff = new RESTClient({
67
- serverUrl: urlMapper(url, ENDPOINTS.BFF),
68
- defaultParams: { client_id: this.clientId, redirect_uri: this.redirectUri },
69
- });
70
- }
71
-
72
- /**
73
- * Close this.popup if it exists and is open
74
- * @private
75
- * @returns {void}
76
- */
77
- _closePopup() {
78
- if (this.popup) {
79
- if (!this.popup.closed) {
80
- this.popup.close();
81
- }
82
- this.popup = null;
83
- }
84
- }
85
-
86
- /**
87
- * Starts the flow for the paylink in a popup or current window
88
- * @param {object} options
89
- * @param {string} options.paylink - The paylink
90
- * @param {boolean} [options.preferPopup=false] - Should we try to open a popup?
91
- * @param {string} [options.redirectUri=this.redirectUri]
92
- * @returns {Window|null} - Returns a reference to the popup window, or `null` if no popup was
93
- * used
94
- */
95
- payWithPaylink({ paylink, preferPopup, redirectUri = this.redirectUri }) {
96
- assert(isUrl(redirectUri), `payWithPaylink(): redirectUri is invalid`);
97
- this._closePopup();
98
- const url = this.purchasePaylinkUrl(paylink, redirectUri);
99
- if (preferPopup) {
100
- this.popup =
101
- popup.open(this.window, url, 'Schibsted account', { width: 360, height: 570 });
102
- if (this.popup) {
103
- return this.popup;
104
- }
105
- }
106
- this.window.location.href = url;
107
- return null;
108
- }
109
-
110
- /**
111
- * Get the url for the end user to review the purchase history
112
- * @param {string} [redirectUri=this.redirectUri]
113
- * @return {string} - The url to the purchase history review page
114
- */
115
- purchaseHistoryUrl(redirectUri = this.redirectUri) {
116
- assert(isUrl(redirectUri), `purchaseHistoryUrl(): redirectUri is invalid`);
117
- return this._spid.makeUrl('account/purchasehistory', { redirect_uri: redirectUri });
118
- }
119
-
120
- /**
121
- * Get the url for the end user to redeem a voucher code
122
- * @param {string} voucherCode
123
- * @param {string} [redirectUri=this.redirectUri]
124
- * @return {string} - The url
125
- */
126
- redeemUrl(voucherCode, redirectUri = this.redirectUri) {
127
- assert(isUrl(redirectUri), `redeemUrl(): redirectUri is invalid`);
128
- return this._spid.makeUrl('account/redeem', { voucher_code: voucherCode });
129
- }
130
-
131
- /**
132
- * @deprecated https://schibsted.ghe.com/user-identity/account-sdk-browser/issues/94
133
- *
134
- * Get the url for the paylink purchase
135
- * @todo Check working-ness for BFF + SPiD
136
- * @param {string} paylinkId
137
- * @param {string} [redirectUri=this.redirectUri]
138
- * @return {string} - The url to the API endpoint
139
- */
140
- purchasePaylinkUrl(paylinkId, redirectUri = this.redirectUri) {
141
- assert(isUrl(redirectUri), `purchasePaylinkUrl(): redirectUri is invalid`);
142
- assert(isNonEmptyString(paylinkId), `purchasePaylinkUrl(): paylinkId is required`);
143
- return this._bff.makeUrl('payment/purchase', {
144
- paylink: paylinkId,
145
- redirect_uri: redirectUri
146
- });
147
- }
148
-
149
- /**
150
- * Get the url for flow to purchase a product
151
- * @param {string} productId
152
- * @param {string} [redirectUri=this.redirectUri]
153
- * @return {string} - The url to the products review page
154
- */
155
- purchaseProductFlowUrl(productId, redirectUri = this.redirectUri) {
156
- assert(isUrl(redirectUri), `purchaseProductUrl(): redirectUri is invalid`);
157
- assert(isNonEmptyString(productId), `purchaseProductFlowUrl(): productId is required`);
158
- return this._bff.makeUrl('flow/checkout', {
159
- response_type: 'code',
160
- flow: 'payment',
161
- product_id: productId,
162
- redirect_uri: redirectUri
163
- });
164
- }
165
-
166
- /**
167
- * Get the url for flow to purchase a product through a campaign and voucher code
168
- * @todo Check working-ness for BFF + SPiD
169
- * @param {string} campaignId
170
- * @param {string} productId
171
- * @param {string} [voucherCode]
172
- * @param {string} [redirectUri=this.redirectUri]
173
- * @return {string} - The url to the products review page
174
- */
175
- purchaseCampaignFlowUrl(campaignId, productId, voucherCode, redirectUri = this.redirectUri) {
176
- assert(isUrl(redirectUri), `purchaseCampaignFlowUrl(): redirectUri is invalid`);
177
- assert(isNonEmptyString(campaignId), `purchaseCampaignFlowUrl(): campaignId is required`);
178
- assert(isNonEmptyString(productId), `purchaseCampaignFlowUrl(): productId is required`);
179
- return this._bff.makeUrl('flow/checkout', {
180
- response_type: 'code',
181
- flow: 'payment',
182
- campaign_id: campaignId,
183
- product_id: productId,
184
- voucher_code: voucherCode,
185
- redirect_uri: redirectUri
186
- });
187
- }
188
-
189
- /**
190
- * @deprecated
191
- * Get the url for flow to purchase a promo code product with ZUORA
192
- * @param {string} code - promocode product code
193
- * @param {string} [state=''] - An opaque value used by the client to maintain state between
194
- * the request and callback. It's also recommended to prevent CSRF
195
- * @param {string} [redirectUri=this.redirectUri]
196
- * @return {string} - The url to the buy promo code product flow
197
- */
198
- purchasePromoCodeProductFlowUrl(code, state = '', redirectUri = this.redirectUri) {
199
- assert(isUrl(redirectUri), `purchasePromoCodeProductFlowUrl(): redirectUri is invalid`);
200
- assert(isNonEmptyString(code), `purchasePromoCodeProductFlowUrl(): code is required`);
201
- assert(isNonEmptyString(this.publisher), `purchasePromoCodeProductFlowUrl(): publisher is required in the constructor`);
202
- return this._bff.makeUrl('payment/purchase/code', {
203
- code,
204
- publisher: this.publisher,
205
- state,
206
- redirect_uri: redirectUri
207
- });
208
- }
209
- }
210
-
211
- export default Payment;
package/src/popup.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Opens a popup
3
- * @param {Window} parentWindow - A reference to the window that will open the popup
4
- * @param {string} url - The URL that the popup will open
5
- * @param {string} [windowName] - A name for the window
6
- * @param {object} [windowFeatures] - Window features for the popup (default ones are usually ok)
7
- * @returns {Window|null} - A reference to the popup window
8
- * @private
9
- */
10
- export function open(parentWindow: Window, url: string, windowName?: string, windowFeatures?: any): Window;
package/src/popup.js DELETED
@@ -1,59 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- import { assert, isObject, isUrl, isFunction } from './validate.js';
6
- import { cloneDefined } from './object.js';
7
-
8
- /**
9
- * Serializes an object to string.
10
- * @memberof core
11
- * @private
12
- * @param {object} obj - for example {a: 'b', c: 1}
13
- * @return {string} - for example 'a=b,c=1'
14
- */
15
- function serialize(obj) {
16
- assert(isObject(obj), `Object must be an object but it is '${obj}'`);
17
- return Object.keys(obj)
18
- .map(key => `${key}=${obj[key]}`)
19
- .join(',');
20
- }
21
-
22
- const defaultWindowFeatures = {
23
- scrollbars: 'yes',
24
- location: 'yes',
25
- status: 'no',
26
- menubar: 'no',
27
- toolbar: 'no',
28
- resizable: 'yes'
29
- };
30
-
31
- /**
32
- * Opens a popup
33
- * @param {Window} parentWindow - A reference to the window that will open the popup
34
- * @param {string} url - The URL that the popup will open
35
- * @param {string} [windowName] - A name for the window
36
- * @param {object} [windowFeatures] - Window features for the popup (default ones are usually ok)
37
- * @returns {Window|null} - A reference to the popup window
38
- * @private
39
- */
40
- export function open(parentWindow, url, windowName = '', windowFeatures = {}) {
41
- assert(isObject(parentWindow), `window was supposed to be an object but it is ${parentWindow}`);
42
- assert(isObject(parentWindow.screen),
43
- `window should be a valid Window object but it lacks a 'screen' property`);
44
- assert(isFunction(parentWindow.open),
45
- `window should be a valid Window object but it lacks an 'open' function`);
46
- assert(isUrl(url), 'Invalid URL for popup');
47
-
48
- const { height, width } = parentWindow.screen;
49
-
50
- let mergedFeatures = cloneDefined(defaultWindowFeatures, windowFeatures);
51
- if (Number.isFinite(mergedFeatures.width) && Number.isFinite(width)) {
52
- mergedFeatures.left = (width - mergedFeatures.width) / 2;
53
- }
54
- if (Number.isFinite(mergedFeatures.height) && Number.isFinite(height)) {
55
- mergedFeatures.top = (height - mergedFeatures.height) / 2;
56
- }
57
- const features = serialize(mergedFeatures);
58
- return parentWindow.open(url, windowName, features);
59
- }
package/src/url.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * A simple utility function that allows looking up URLs from a dictionary
3
- * @memberof core
4
- * @param {string} url - A url like http://example.com, or a key used for lookup
5
- * @param {object<string,string>} urlMap - A map of URLs like
6
- * `{ DEV: 'http://dev.example.com' }`
7
- * @throws {SDKError} - If the url is not an string or is an empty string
8
- * @return {string} The url that points to the server
9
- */
10
- export function urlMapper(url: string, urlMap: any): string;
package/src/validate.d.ts DELETED
@@ -1,64 +0,0 @@
1
- /**
2
- * A utility function that throws an SDKError if an assertion fails. It's mostly useful for
3
- * validating function inputs.
4
- * @memberof core
5
- * @param {boolean} condition - The condition that we're asserting
6
- * @param {string} [message = Assertion failed] - The error message
7
- * @throws {SDKError} - If the condition is falsy it throws the appropriate error
8
- * @return {void}
9
- */
10
- export function assert(condition: boolean, message?: string): void;
11
- /**
12
- * Checks if a value is a string or not
13
- * @memberof core
14
- * @param {*} value - The value to check
15
- * @return {boolean}
16
- */
17
- export function isStr(value: any): boolean;
18
- /**
19
- * Checks if a value is a non-empty string
20
- * @memberof core
21
- * @param {*} value - The value to check
22
- * @return {boolean}
23
- */
24
- export function isNonEmptyString(value: any): boolean;
25
- /**
26
- * checks if a given value is an object (but not null)
27
- * @memberof core
28
- * @param {*} value - The value to check
29
- * @return {boolean}
30
- */
31
- export function isObject(value: any): boolean;
32
- /**
33
- * Checks if a given value is an object with at least one own key
34
- * @memberof core
35
- * @param {*} value - The value to check
36
- * @return {boolean}
37
- */
38
- export function isNonEmptyObj(value: any): boolean;
39
- /**
40
- * Checks if a given string is a valid URL
41
- * @memberof core
42
- * @param {string} value - The string to be tested
43
- * @param {...string} mandatoryFields - A list of mandatory fields that should exist in the parsed
44
- * URL object
45
- * @return {boolean}
46
- */
47
- export function isUrl(value: string, ...mandatoryFields: string[]): boolean;
48
- /**
49
- * Checks if a given value is a function
50
- * @memberof core
51
- * @param {*} value - The value to check
52
- * @return {boolean}
53
- */
54
- export function isFunction(value: any): boolean;
55
- /**
56
- * Checks if a string matches any of the strings in a set of possibilities
57
- * @memberof core
58
- * @param {string} value
59
- * @param {string[]} possibilities - An array of strings that'll be used to check the string
60
- * inclusion. Note that for performance reasons, we don't validate this parameter.
61
- * @param {boolean} [caseSensitive=false] - Should the check be case sensitive
62
- * @return {boolean}
63
- */
64
- export function isStrIn(value: string, possibilities: string[], caseSensitive?: boolean): boolean;
package/src/version.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const version: string;
2
- export default version;