@schibsted/account-sdk-browser 6.0.0-alpha.1 → 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.
- package/README.md +8 -33
- package/dist/RESTClient.d.ts +91 -0
- package/dist/SDKError.d.ts +27 -0
- package/dist/cache.d.ts +65 -0
- package/dist/config.d.ts +86 -0
- package/dist/global-registry.d.ts +23 -0
- package/dist/globals.d.ts +13 -0
- package/dist/identity-s4nofYmB.js +370 -0
- package/dist/identity-s4nofYmB.js.map +1 -0
- package/dist/identity.d.ts +523 -0
- package/dist/identity.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/monetization.d.ts +94 -0
- package/dist/monetization.js +72 -0
- package/dist/monetization.js.map +1 -0
- package/{src → dist}/object.d.ts +4 -9
- package/dist/popup.d.ts +9 -0
- package/{src → dist}/spidTalk.d.ts +4 -6
- package/dist/url.d.ts +8 -0
- package/dist/validate.d.ts +50 -0
- package/dist/version-spE-k97g.js +289 -0
- package/dist/version-spE-k97g.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/package.json +38 -22
- package/src/RESTClient.ts +226 -0
- package/src/SDKError.ts +59 -0
- package/src/{cache.js → cache.ts} +52 -37
- package/src/{config.js → config.ts} +7 -32
- package/src/global-registry.ts +39 -0
- package/src/globals.ts +10 -0
- package/src/{identity.js → identity.ts} +539 -437
- package/{index.js → src/index.ts} +1 -3
- package/src/{monetization.js → monetization.ts} +77 -48
- package/src/{object.js → object.ts} +8 -15
- package/src/popup.ts +74 -0
- package/src/{spidTalk.js → spidTalk.ts} +10 -12
- package/src/{url.js → url.ts} +6 -10
- package/src/{validate.js → validate.ts} +26 -42
- package/src/{version.js → version.ts} +1 -2
- package/identity.d.ts +0 -1
- package/identity.js +0 -5
- package/index.d.ts +0 -4
- 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/cache.d.ts +0 -64
- package/src/config.d.ts +0 -34
- package/src/global-registry.js +0 -20
- package/src/identity.d.ts +0 -679
- package/src/monetization.d.ts +0 -80
- 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
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ For example if your `pre` domain is pre.sdk-example.com, and it uses id.pre.sdk-
|
|
|
24
24
|
domain, your local domain should be local.sdk-example.com.
|
|
25
25
|
|
|
26
26
|
1. Do `npm install --save @schibsted/account-sdk-browser`
|
|
27
|
-
2. Use this library as you would any other npm module: `import { Identity, Monetization
|
|
27
|
+
2. Use this library as you would any other npm module: `import { Identity, Monetization } from '@schibsted/account-sdk-browser'`.
|
|
28
28
|
3. Build your site as you prefer. This library is published as ES modules and uses modern JavaScript
|
|
29
29
|
syntax (including async/await and other ES2017 and WHATWG features). We recommend that you do
|
|
30
30
|
any transpilation yourself for the browser versions you need to cater to. We do not add polyfills.
|
|
@@ -41,8 +41,8 @@ Follow the [migration guide](./MIGRATION.md).
|
|
|
41
41
|
|
|
42
42
|
1. Ensure that your site has no site specific terms and conditions in the Schibsted account login flow.
|
|
43
43
|
1. Define rules for when and how often the simplified login prompt should be shown to unique users on your site. How you do this is up to you, but we recommend starting with showing the prompt once per user before potentially increasing this frequency over time.
|
|
44
|
-
1. Set up a function to check if users landing on your domain [is logged in](https://schibsted.github.io/account-sdk-browser/Identity.html#
|
|
45
|
-
1. If the user is not logged-in to your site, call the [showSimplifiedLoginWidget](https://schibsted.github.io/account-sdk-browser/Identity.html#
|
|
44
|
+
1. Set up a function to check if users landing on your domain [is logged in](https://schibsted.github.io/account-sdk-browser/classes/Identity.html#isloggedin) to your site.
|
|
45
|
+
1. If the user is not logged-in to your site, call the [showSimplifiedLoginWidget](https://schibsted.github.io/account-sdk-browser/classes/Identity.html#showsimplifiedloginwidget) function. The `showSimplifiedLoginWidget` accepts the same params as login function (`state` is required, it might be string or async function). If the simplified login prompt is to be loaded, `showSimplifiedLoginWidget` will return `true`.
|
|
46
46
|
1. Set up a way to store information about which users have been shown the simplified login prompt. How you do this is up to you, but one way is to use localStorage. Use this information to execute on the rules defined in #2.
|
|
47
47
|
|
|
48
48
|
## Example project
|
|
@@ -66,7 +66,7 @@ This allows you to call Schibsted Account APIs on behalf of that user.
|
|
|
66
66
|
## Events
|
|
67
67
|
|
|
68
68
|
The SDK fires events on the instances when something we deem interesting is happening. For example the
|
|
69
|
-
[Identity](https://schibsted.github.io/account-sdk-browser/Identity.html) class
|
|
69
|
+
[Identity](https://schibsted.github.io/account-sdk-browser/classes/Identity.html) class
|
|
70
70
|
emits some events when the user is logged in or logged out. This SDK uses a familar interface that's
|
|
71
71
|
very similar to Node's [EventEmitter](https://nodejs.org/api/events.html). The most important
|
|
72
72
|
methods are `.on(eventName, listener)` (to subscribe to an event) and `.off(eventName, listener)`
|
|
@@ -79,7 +79,6 @@ Events are emitted for:
|
|
|
79
79
|
| ------------ | ----------------------- |
|
|
80
80
|
| Identity | `schIdentity:ready` |
|
|
81
81
|
| Monetization | `schMonetization:ready` |
|
|
82
|
-
| Payment | `schPayment:ready` |
|
|
83
82
|
|
|
84
83
|
```js
|
|
85
84
|
window.addEventListener('schIdentity:ready', e => {
|
|
@@ -188,10 +187,10 @@ Schibsted account relies on browser cookies to determine whether a user is recog
|
|
|
188
187
|
The SDK provides functions that can be used to check if the user that's visiting your site is
|
|
189
188
|
already a Schibsted user or not.
|
|
190
189
|
|
|
191
|
-
* [Identity#isLoggedIn](https://schibsted.github.io/account-sdk-browser/Identity.html#
|
|
190
|
+
* [Identity#isLoggedIn](https://schibsted.github.io/account-sdk-browser/classes/Identity.html#isloggedin)
|
|
192
191
|
tells you if the user that is visiting your site is already logged in to Schibsted account or not.
|
|
193
192
|
|
|
194
|
-
* [Identity#isConnected](https://schibsted.github.io/account-sdk-browser/Identity.html#
|
|
193
|
+
* [Identity#isConnected](https://schibsted.github.io/account-sdk-browser/classes/Identity.html#isconnected)
|
|
195
194
|
tells you if the user is connected to your client. A user might have `isLoggedIn=true` and at the
|
|
196
195
|
same time `isConnected=false` if they have logged in to Schibsted account, but not accepted terms
|
|
197
196
|
and privacy policy for your site.
|
|
@@ -203,13 +202,13 @@ will just ask them to accept those terms and redirect them right back to your si
|
|
|
203
202
|
#### Logging out
|
|
204
203
|
|
|
205
204
|
If you want to log the user out of Schibsted account, you can call
|
|
206
|
-
[Identity#logout](https://schibsted.github.io/account-sdk-browser/Identity.html#logout). This
|
|
205
|
+
[Identity#logout](https://schibsted.github.io/account-sdk-browser/classes/Identity.html#logout). This
|
|
207
206
|
will remove the Schibsted account brand session. User will still be logged into Schibsted account.
|
|
208
207
|
|
|
209
208
|
## Monetization
|
|
210
209
|
|
|
211
210
|
The preferred method for checking whether a user has access to a product/subscription is
|
|
212
|
-
[Monetization#hasAccess](https://schibsted.github.io/account-sdk-browser/Monetization.html#
|
|
211
|
+
[Monetization#hasAccess](https://schibsted.github.io/account-sdk-browser/classes/Monetization.html#hasaccess).
|
|
213
212
|
It requires using Session Service, and supports both Schibsted account productId's and Zuora
|
|
214
213
|
feature id's.
|
|
215
214
|
|
|
@@ -235,30 +234,6 @@ try {
|
|
|
235
234
|
}
|
|
236
235
|
```
|
|
237
236
|
|
|
238
|
-
## Payment
|
|
239
|
-
|
|
240
|
-
This class provides methods for paying with a so-called paylink, buying a product, getting links to
|
|
241
|
-
pages for redeeming voucher codes, reviewing payment history, and more.
|
|
242
|
-
|
|
243
|
-
#### Example
|
|
244
|
-
|
|
245
|
-
```javascript
|
|
246
|
-
import { Payment } from '@schibsted/account-sdk-browser';
|
|
247
|
-
|
|
248
|
-
const paymentSDK = new Payment({
|
|
249
|
-
clientId: '56e9a5d1eee0000000000000',
|
|
250
|
-
redirectUri: 'https://awesomenews.site', // ensure it's listed in selfservice
|
|
251
|
-
env: 'PRE', // Schibsted account env. A url or a special key: 'PRE', 'PRO' or 'PRO_NO'
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// Get the url to paymentSDK with paylink
|
|
255
|
-
const paylink = '...';
|
|
256
|
-
const paylinkUrl = paymentSDK.purchasePaylinkUrl(paylink);
|
|
257
|
-
|
|
258
|
-
// Or another example --- pay with paylink in a popup
|
|
259
|
-
paymentSDK.payWithPaylink(paylink);
|
|
260
|
-
```
|
|
261
|
-
|
|
262
237
|
#### Cookies
|
|
263
238
|
|
|
264
239
|
There are some cookies used by Schibsted account. They should all be considered opaque on the
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
type FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
/**
|
|
3
|
+
* The value of a single query parameter; `undefined` entries are skipped.
|
|
4
|
+
*/
|
|
5
|
+
type QueryValue = string | number | boolean | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Query parameters appended to a request URL.
|
|
8
|
+
*/
|
|
9
|
+
type QueryParams = Record<string, QueryValue>;
|
|
10
|
+
/**
|
|
11
|
+
* HTTP method used for a request.
|
|
12
|
+
*/
|
|
13
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
14
|
+
/**
|
|
15
|
+
* This class can be used for creating a wrapper around a server and all its endpoints.
|
|
16
|
+
* Its functionality is extended by {@link JSONPClient}
|
|
17
|
+
* Creates a client to a REST server. While useful stand-alone, it's also used for some other
|
|
18
|
+
* types of client that change some functionalities.
|
|
19
|
+
* @throws {SDKError} - If any of options are invalid
|
|
20
|
+
* @summary The simplest way to communicate to a REST endpoint without any
|
|
21
|
+
* special authentication
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
export declare class RESTClient {
|
|
25
|
+
url: URL;
|
|
26
|
+
defaultParams: QueryParams;
|
|
27
|
+
log?: Function;
|
|
28
|
+
fetch: FetchFunction;
|
|
29
|
+
/**
|
|
30
|
+
* @param options
|
|
31
|
+
* @param options.serverUrl - The URL to the server eg.
|
|
32
|
+
* https://login.schibsted.com or a URL key like 'DEV' in combination with {@link envDic}.
|
|
33
|
+
* @param options.envDic - A dictionary that will be used for looking up
|
|
34
|
+
* {@link serverUrl} keys. If serverUrl is always a URL, you don't need this.
|
|
35
|
+
* @param options.fetch - The fetch function to use. It can be native
|
|
36
|
+
* or a polyfill
|
|
37
|
+
* @param options.log - A function that will be called with log messages about
|
|
38
|
+
* request and response
|
|
39
|
+
* @param options.defaultParams - Query parameters added to every request
|
|
40
|
+
*/
|
|
41
|
+
constructor({ serverUrl, envDic, fetch, log, defaultParams, }: {
|
|
42
|
+
serverUrl?: string;
|
|
43
|
+
envDic?: Record<string, string>;
|
|
44
|
+
fetch?: FetchFunction;
|
|
45
|
+
log?: Function;
|
|
46
|
+
defaultParams?: QueryParams;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Makes the actual call to the server and deals with headers, data objects and the edge cases.
|
|
50
|
+
* Please note that this method expects the response to be in JSON format. However, it'll not
|
|
51
|
+
* parse the response if its code is not in the 200 range.
|
|
52
|
+
* @param options - An obligatory options object
|
|
53
|
+
* @param options.method - The HTTP request method, e.g. 'GET' or 'POST'
|
|
54
|
+
* @param options.pathname - The path to the endpoint like 'api/2/endpoint-name'
|
|
55
|
+
* @param options.data - Query parameters added to the request URL
|
|
56
|
+
* @param options.headers - Request headers as a plain key/value map
|
|
57
|
+
* @param options.useDefaultParams - Should we add the defaultParams to the query?
|
|
58
|
+
* @param options.fetchOptions - Additional fetch options
|
|
59
|
+
* @throws {SDKError} - If the call can't be made for whatever reason.
|
|
60
|
+
*/
|
|
61
|
+
go({ method, headers, pathname, data, useDefaultParams, fetchOptions, }: {
|
|
62
|
+
method: HttpMethod;
|
|
63
|
+
pathname: string;
|
|
64
|
+
data?: QueryParams;
|
|
65
|
+
headers?: Record<string, string>;
|
|
66
|
+
useDefaultParams?: boolean;
|
|
67
|
+
fetchOptions?: RequestInit;
|
|
68
|
+
}): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a url that points to an endpoint in the server
|
|
71
|
+
* @param pathname - WHATWG pathname ie. 'api/2/endpoint-name'
|
|
72
|
+
* @param query - Query parameters to serialize into the query string
|
|
73
|
+
* @param useDefaultParams - Should we add the defaultParams to the query?
|
|
74
|
+
*/
|
|
75
|
+
makeUrl(pathname?: string, query?: QueryParams, useDefaultParams?: boolean): string;
|
|
76
|
+
/**
|
|
77
|
+
* Make a GET request
|
|
78
|
+
* @param pathname - WHATWG pathname ie. 'api/2/endpoint-name'
|
|
79
|
+
* @param data - Query parameters
|
|
80
|
+
*/
|
|
81
|
+
get(pathname: string, data?: QueryParams): Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* Construct query string for WHATWG urls
|
|
84
|
+
* @private
|
|
85
|
+
* @param query - Query parameters to generate the query string from
|
|
86
|
+
* @param useDefaultParams - Use defaultParams or not
|
|
87
|
+
* @param defaultParams - Default params
|
|
88
|
+
*/
|
|
89
|
+
private static search;
|
|
90
|
+
}
|
|
91
|
+
export default RESTClient;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error class thrown by all SDK methods on failure.
|
|
3
|
+
*
|
|
4
|
+
* All rejected promises from API calls reject with an instance of this class.
|
|
5
|
+
*/
|
|
6
|
+
export default class SDKError extends Error {
|
|
7
|
+
/** HTTP status code from the server error payload;
|
|
8
|
+
* declared explicitly to allow numeric comparisons without type-casting.
|
|
9
|
+
*/
|
|
10
|
+
code?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Properties copied from the server error object.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* @param message - Human-readable error message
|
|
18
|
+
* @param errorObject - Optional server error payload. All enumerable properties are
|
|
19
|
+
* shallow-copied onto this instance.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message: string, errorObject?: Record<string, unknown>);
|
|
22
|
+
/**
|
|
23
|
+
* Returns a multi-line string with the error name, message, and any other properties copied
|
|
24
|
+
* from the server error payload.
|
|
25
|
+
*/
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache implementation used when web storage is available. Wraps a `Storage` instance.
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
declare class WebStorageCache {
|
|
6
|
+
store: Storage;
|
|
7
|
+
get: (key: string) => string | null;
|
|
8
|
+
set: (key: string, value: string) => void;
|
|
9
|
+
delete: (key: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Create web storage cache object
|
|
12
|
+
* @param store - A reference to either `sessionStorage` or `localStorage` from a
|
|
13
|
+
* `Window` object
|
|
14
|
+
*/
|
|
15
|
+
constructor(store: Storage);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Cache implementation used when web storage is not available. Stores entries in an in-memory object.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
declare class LiteralCache {
|
|
22
|
+
store: Record<string, string>;
|
|
23
|
+
get: (key: string) => string | undefined;
|
|
24
|
+
set: (key: string, value: string) => void;
|
|
25
|
+
delete: (key: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Create JS object literal cache object
|
|
28
|
+
*/
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Cache class that attempts WebStorage (session/local storage), and falls back to JS object literal
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
export default class Cache {
|
|
36
|
+
cache: WebStorageCache | LiteralCache;
|
|
37
|
+
type: string;
|
|
38
|
+
/**
|
|
39
|
+
* @param storeProvider - A function to return a WebStorage instance (either
|
|
40
|
+
* `sessionStorage` or `localStorage` from a `Window` object)
|
|
41
|
+
* @throws {SDKError} - If sessionStorage or localStorage are not accessible
|
|
42
|
+
*/
|
|
43
|
+
constructor(storeProvider?: () => Storage);
|
|
44
|
+
/**
|
|
45
|
+
* Get a value from cache (checks that the object has not expired)
|
|
46
|
+
* @param key
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
get(key: string): unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Set a cache entry
|
|
52
|
+
* @param key
|
|
53
|
+
* @param value
|
|
54
|
+
* @param expiresIn - Value in milliseconds until the entry expires
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
set(key: string, value: unknown, expiresIn?: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Delete a cache entry
|
|
60
|
+
* @param key
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
delete(key: string): void;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core configuration used by the SDK.
|
|
3
|
+
* - `ENDPOINTS.SPiD` — SPiD endpoints per environment
|
|
4
|
+
* - `ENDPOINTS.BFF` — Endpoints used with new GDPR-compliant web flows
|
|
5
|
+
* - `ENDPOINTS.SESSION_SERVICE` — Endpoints to check global user session data
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
declare const config: {
|
|
9
|
+
readonly ENDPOINTS: {
|
|
10
|
+
readonly SPiD: {
|
|
11
|
+
readonly LOCAL: "http://id.localhost";
|
|
12
|
+
readonly DEV: "https://identity-dev.schibsted.com";
|
|
13
|
+
readonly PRE: "https://identity-pre.schibsted.com";
|
|
14
|
+
readonly PRO: "https://login.schibsted.com";
|
|
15
|
+
readonly PRO_NO: "https://payment.schibsted.no";
|
|
16
|
+
readonly PRO_FI: "https://login.schibsted.fi";
|
|
17
|
+
readonly PRO_DK: "https://login.schibsted.dk";
|
|
18
|
+
};
|
|
19
|
+
readonly BFF: {
|
|
20
|
+
readonly LOCAL: "http://id.localhost/authn/";
|
|
21
|
+
readonly DEV: "https://identity-dev.schibsted.com/authn/";
|
|
22
|
+
readonly PRE: "https://identity-pre.schibsted.com/authn/";
|
|
23
|
+
readonly PRO: "https://login.schibsted.com/authn/";
|
|
24
|
+
readonly PRO_NO: "https://payment.schibsted.no/authn/";
|
|
25
|
+
readonly PRO_FI: "https://login.schibsted.fi/authn/";
|
|
26
|
+
readonly PRO_DK: "https://login.schibsted.dk/authn/";
|
|
27
|
+
};
|
|
28
|
+
readonly SESSION_SERVICE: {
|
|
29
|
+
readonly LOCAL: "http://session-service.id.localhost";
|
|
30
|
+
readonly DEV: "https://session-service.identity-dev.schibsted.com";
|
|
31
|
+
readonly PRE: "https://session-service.identity-pre.schibsted.com";
|
|
32
|
+
readonly PRO: "https://session-service.login.schibsted.com";
|
|
33
|
+
readonly PRO_NO: "https://session-service.payment.schibsted.no";
|
|
34
|
+
readonly PRO_FI: "https://session-service.login.schibsted.fi";
|
|
35
|
+
readonly PRO_DK: "https://session-service.login.schibsted.dk";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly NAMESPACE: {
|
|
39
|
+
readonly LOCAL: "id.localhost";
|
|
40
|
+
readonly DEV: "schibsted.com";
|
|
41
|
+
readonly PRE: "schibsted.com";
|
|
42
|
+
readonly PRO: "schibsted.com";
|
|
43
|
+
readonly PRO_NO: "spid.no";
|
|
44
|
+
readonly PRO_FI: "schibsted.fi";
|
|
45
|
+
readonly PRO_DK: "schibsted.dk";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export default config;
|
|
49
|
+
export declare const ENDPOINTS: {
|
|
50
|
+
readonly SPiD: {
|
|
51
|
+
readonly LOCAL: "http://id.localhost";
|
|
52
|
+
readonly DEV: "https://identity-dev.schibsted.com";
|
|
53
|
+
readonly PRE: "https://identity-pre.schibsted.com";
|
|
54
|
+
readonly PRO: "https://login.schibsted.com";
|
|
55
|
+
readonly PRO_NO: "https://payment.schibsted.no";
|
|
56
|
+
readonly PRO_FI: "https://login.schibsted.fi";
|
|
57
|
+
readonly PRO_DK: "https://login.schibsted.dk";
|
|
58
|
+
};
|
|
59
|
+
readonly BFF: {
|
|
60
|
+
readonly LOCAL: "http://id.localhost/authn/";
|
|
61
|
+
readonly DEV: "https://identity-dev.schibsted.com/authn/";
|
|
62
|
+
readonly PRE: "https://identity-pre.schibsted.com/authn/";
|
|
63
|
+
readonly PRO: "https://login.schibsted.com/authn/";
|
|
64
|
+
readonly PRO_NO: "https://payment.schibsted.no/authn/";
|
|
65
|
+
readonly PRO_FI: "https://login.schibsted.fi/authn/";
|
|
66
|
+
readonly PRO_DK: "https://login.schibsted.dk/authn/";
|
|
67
|
+
};
|
|
68
|
+
readonly SESSION_SERVICE: {
|
|
69
|
+
readonly LOCAL: "http://session-service.id.localhost";
|
|
70
|
+
readonly DEV: "https://session-service.identity-dev.schibsted.com";
|
|
71
|
+
readonly PRE: "https://session-service.identity-pre.schibsted.com";
|
|
72
|
+
readonly PRO: "https://session-service.login.schibsted.com";
|
|
73
|
+
readonly PRO_NO: "https://session-service.payment.schibsted.no";
|
|
74
|
+
readonly PRO_FI: "https://session-service.login.schibsted.fi";
|
|
75
|
+
readonly PRO_DK: "https://session-service.login.schibsted.dk";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export declare const NAMESPACE: {
|
|
79
|
+
readonly LOCAL: "id.localhost";
|
|
80
|
+
readonly DEV: "schibsted.com";
|
|
81
|
+
readonly PRE: "schibsted.com";
|
|
82
|
+
readonly PRO: "schibsted.com";
|
|
83
|
+
readonly PRO_NO: "spid.no";
|
|
84
|
+
readonly PRO_FI: "schibsted.fi";
|
|
85
|
+
readonly PRO_DK: "schibsted.dk";
|
|
86
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of the SDK instance properties that can be registered on the global {@link Window} object.
|
|
3
|
+
*/
|
|
4
|
+
type Property = 'schIdentity' | 'schMonetization';
|
|
5
|
+
/**
|
|
6
|
+
* Registers an SDK instance on the global {@link Window} object's given property and dispatches a ready event.
|
|
7
|
+
*
|
|
8
|
+
* The dispatched event is a {@link CustomEvent} fired on `global` (i.e. `window`) with:
|
|
9
|
+
* - name: `${property}:ready` (e.g. `"schIdentity:ready"` or `"schMonetization:ready"`)
|
|
10
|
+
* - `detail.instance`: the registered SDK instance
|
|
11
|
+
*
|
|
12
|
+
* @typeParam T - Constrained to {@link Property}; inferred from the `property` argument.
|
|
13
|
+
* @param global - The `Window` object to register on.
|
|
14
|
+
* @param property - The window property name to assign the instance to, 'schIdentity' or 'schMonetization'.
|
|
15
|
+
* @param instance - The SDK instance to register. Must be non-nullable.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* registerAndDispatchInGlobal(window, 'schIdentity', identityInstance);
|
|
19
|
+
* / window.schIdentity === identityInstance
|
|
20
|
+
* / CustomEvent 'schIdentity:ready' has been dispatched on window
|
|
21
|
+
*/
|
|
22
|
+
export declare const registerAndDispatchInGlobal: <T extends Property>(global: Window, property: T, instance: NonNullable<Window[T]>) => void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Identity } from './identity.js';
|
|
2
|
+
import { Monetization } from './monetization.js';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
schIdentity?: Identity;
|
|
6
|
+
schMonetization?: Monetization;
|
|
7
|
+
SPiD?: {
|
|
8
|
+
Talk?: {
|
|
9
|
+
response?: (callbackName: string, data: unknown) => unknown;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|