Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sitecore-cloudsdk/core

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sitecore-cloudsdk/core - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0-rc.0

browser.cjs

39

dist/cjs/package.json
{
"name": "@sitecore-cloudsdk/core",
"version": "0.3.1",
"version": "0.4.0-rc.0",
"license": "Apache-2.0",
"main": "dist/cjs/src/index.js",
"module": "dist/esm/src/index.js",
"types": "dist/esm/src/index.d.ts",
"exports": {
".": {
"types": {
"require": "./dist/cjs/src/index.d.ts",
"default": "./dist/esm/src/index.d.ts"
},
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
"./browser": {
"import": "./browser.js",
"require": "./browser.cjs",
"types": "./browser.d.ts"
},
"./server": {
"import": "./server.js",
"require": "./server.cjs",
"types": "./server.d.ts"
},
"./internal": {
"types": "./internal.d.ts",
"import": "./internal.js",
"require": "./internal.js"
}
},
"dependencies": {
"@sitecore-cloudsdk/utils": "^0.3.1",
"@sitecore-cloudsdk/utils": "^0.4.0-rc.0",
"debug": "^4.3.4"

@@ -29,3 +33,12 @@ },

"dist",
"README.md"
"README.md",
"browser.js",
"browser.cjs",
"browser.d.ts",
"server.js",
"server.cjs",
"server.d.ts",
"internal.js",
"internal.cjs",
"internal.d.ts"
],

@@ -32,0 +45,0 @@ "engines": {

@@ -9,5 +9,8 @@ export declare const LIBRARY_VERSION: string;

export declare enum ErrorMessages {
IE_0001 = "[IE-0001] You are trying to run a browser-side function on the server side. On the server side, run the server-side equivalent of the function, available in \"server\" modules.",
IE_0003 = "[IE-0003] Unable to set the \"sc_{SitecoreEdgeContextId}\" cookie because the browser ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.",
IE_0008 = "[IE-0008] You must first initialize the \"core\" package. Run the \"init\" function.",
IE_0011 = "[IE-0011] Unable to set the \"sc_{SitecoreEdgeContextId}_personalize\" cookie because the guest ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.",
IE_0012 = "[IE-0012] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/browser\", then run \"CloudSDK().initialize()\".",
IE_0013 = "[IE-0013] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/server\", then run \"await CloudSDK().initialize()\".",
IV_0001 = "[IV-0001] Incorrect value for \"sitecoreEdgeUrl\". Set the value to a valid URL string.",

@@ -14,0 +17,0 @@ MV_0001 = "[MV-0001] \"sitecoreEdgeContextId\" is required.",

@@ -20,5 +20,8 @@ "use strict";

(function (ErrorMessages) {
ErrorMessages["IE_0001"] = "[IE-0001] You are trying to run a browser-side function on the server side. On the server side, run the server-side equivalent of the function, available in \"server\" modules.";
ErrorMessages["IE_0003"] = "[IE-0003] Unable to set the \"sc_{SitecoreEdgeContextId}\" cookie because the browser ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
ErrorMessages["IE_0008"] = "[IE-0008] You must first initialize the \"core\" package. Run the \"init\" function.";
ErrorMessages["IE_0011"] = "[IE-0011] Unable to set the \"sc_{SitecoreEdgeContextId}_personalize\" cookie because the guest ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
ErrorMessages["IE_0012"] = "[IE-0012] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/browser\", then run \"CloudSDK().initialize()\".";
ErrorMessages["IE_0013"] = "[IE-0013] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/server\", then run \"await CloudSDK().initialize()\".";
ErrorMessages["IV_0001"] = "[IV-0001] Incorrect value for \"sitecoreEdgeUrl\". Set the value to a valid URL string.";

@@ -25,0 +28,0 @@ ErrorMessages["MV_0001"] = "[MV-0001] \"sitecoreEdgeContextId\" is required.";

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCookies = void 0;
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
const utils_1 = require("@sitecore-cloudsdk/utils");
const fetch_browser_id_from_edge_proxy_1 = require("../init/fetch-browser-id-from-edge-proxy");
const fetch_browser_id_from_edge_proxy_1 = require("../browser-id/fetch-browser-id-from-edge-proxy");
const get_guest_id_1 = require("../init/get-guest-id");
const get_default_cookie_attributes_1 = require("./get-default-cookie-attributes");
const get_guest_id_1 = require("../init/get-guest-id");
/**

@@ -10,0 +10,0 @@ * Creates and adds the cookie to the document

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleHttpCookie = void 0;
const utils_1 = require("@sitecore-cloudsdk/utils");
const fetch_browser_id_from_edge_proxy_1 = require("../init/fetch-browser-id-from-edge-proxy");
const fetch_browser_id_from_edge_proxy_1 = require("../browser-id/fetch-browser-id-from-edge-proxy");
const get_guest_id_1 = require("../init/get-guest-id");
const get_default_cookie_attributes_1 = require("./get-default-cookie-attributes");
const get_guest_id_1 = require("../init/get-guest-id");
/**

@@ -10,0 +9,0 @@ * Handles HTTP Cookie operations for setting the browser ID cookie in the request and response.

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleNextJsMiddlewareCookie = void 0;
const fetch_browser_id_from_edge_proxy_1 = require("../init/fetch-browser-id-from-edge-proxy");
const fetch_browser_id_from_edge_proxy_1 = require("../browser-id/fetch-browser-id-from-edge-proxy");
const get_guest_id_1 = require("../init/get-guest-id");
const get_cookie_value_from_middleware_request_1 = require("./get-cookie-value-from-middleware-request");
const get_default_cookie_attributes_1 = require("./get-default-cookie-attributes");
const get_guest_id_1 = require("../init/get-guest-id");
/**

@@ -10,0 +9,0 @@ * Handles the Middleware Request and sets a cookie with the provided 'cookieName' and 'cookieValue'.

"use strict";
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGuestId = void 0;
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
const consts_1 = require("../consts");

@@ -6,0 +6,0 @@ /**

@@ -12,2 +12,3 @@ import type { Request, Response } from '@sitecore-cloudsdk/utils';

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/

@@ -14,0 +15,0 @@ export declare function getSettingsServer(): Settings;

@@ -20,2 +20,3 @@ "use strict";

exports.setCoreSettings = setCoreSettings;
/* eslint-disable max-len */
/**

@@ -29,3 +30,5 @@ * Initializes the core settings for browser-based applications.

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/
/* eslint-enable max-len */
function getSettingsServer() {

@@ -32,0 +35,0 @@ if (!coreSettings)

@@ -20,2 +20,3 @@ import type { BrowserSettings, Settings } from '../settings/interfaces';

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/

@@ -28,1 +29,15 @@ export declare function initCore(settingsInput: BrowserSettings): Promise<void>;

export declare function setCookiePromise(promise: Promise<void>): void;
interface Engage {
[key: string]: any;
getBrowserId?: () => string;
versions?: {
personalize?: string | undefined;
events?: string | undefined;
};
}
declare global {
interface Window {
Engage: Engage;
}
}
export {};

@@ -31,2 +31,3 @@ "use strict";

let createCookiesPromise = null;
/* eslint-disable max-len */
/**

@@ -40,3 +41,5 @@ * Initializes the core settings for browser-based applications.

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/
/* eslint-enable max-len */
async function initCore(settingsInput) {

@@ -43,0 +46,0 @@ (0, debug_1.debug)(namespaces_1.CORE_NAMESPACE)('coreClient library initialized');

{
"name": "@sitecore-cloudsdk/core",
"version": "0.3.1",
"version": "0.4.0-rc.0",
"license": "Apache-2.0",
"main": "dist/cjs/src/index.js",
"module": "dist/esm/src/index.js",
"types": "dist/esm/src/index.d.ts",
"exports": {
".": {
"types": {
"require": "./dist/cjs/src/index.d.ts",
"default": "./dist/esm/src/index.d.ts"
},
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
"./browser": {
"import": "./browser.js",
"require": "./browser.cjs",
"types": "./browser.d.ts"
},
"./server": {
"import": "./server.js",
"require": "./server.cjs",
"types": "./server.d.ts"
},
"./internal": {
"types": "./internal.d.ts",
"import": "./internal.js",
"require": "./internal.js"
}
},
"dependencies": {
"@sitecore-cloudsdk/utils": "^0.3.1",
"@sitecore-cloudsdk/utils": "^0.4.0-rc.0",
"debug": "^4.3.4"

@@ -29,3 +33,12 @@ },

"dist",
"README.md"
"README.md",
"browser.js",
"browser.cjs",
"browser.d.ts",
"server.js",
"server.cjs",
"server.d.ts",
"internal.js",
"internal.cjs",
"internal.d.ts"
],

@@ -32,0 +45,0 @@ "engines": {

@@ -9,5 +9,8 @@ export declare const LIBRARY_VERSION: string;

export declare enum ErrorMessages {
IE_0001 = "[IE-0001] You are trying to run a browser-side function on the server side. On the server side, run the server-side equivalent of the function, available in \"server\" modules.",
IE_0003 = "[IE-0003] Unable to set the \"sc_{SitecoreEdgeContextId}\" cookie because the browser ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.",
IE_0008 = "[IE-0008] You must first initialize the \"core\" package. Run the \"init\" function.",
IE_0011 = "[IE-0011] Unable to set the \"sc_{SitecoreEdgeContextId}_personalize\" cookie because the guest ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.",
IE_0012 = "[IE-0012] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/browser\", then run \"CloudSDK().initialize()\".",
IE_0013 = "[IE-0013] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/server\", then run \"await CloudSDK().initialize()\".",
IV_0001 = "[IV-0001] Incorrect value for \"sitecoreEdgeUrl\". Set the value to a valid URL string.",

@@ -14,0 +17,0 @@ MV_0001 = "[MV-0001] \"sitecoreEdgeContextId\" is required.",

@@ -14,5 +14,8 @@ // © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.

(function (ErrorMessages) {
ErrorMessages["IE_0001"] = "[IE-0001] You are trying to run a browser-side function on the server side. On the server side, run the server-side equivalent of the function, available in \"server\" modules.";
ErrorMessages["IE_0003"] = "[IE-0003] Unable to set the \"sc_{SitecoreEdgeContextId}\" cookie because the browser ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
ErrorMessages["IE_0008"] = "[IE-0008] You must first initialize the \"core\" package. Run the \"init\" function.";
ErrorMessages["IE_0011"] = "[IE-0011] Unable to set the \"sc_{SitecoreEdgeContextId}_personalize\" cookie because the guest ID could not be retrieved from the server. Make sure to set the correct values for \"sitecoreEdgeContextId\" and \"siteName\". If the issue persists, try again later or use try-catch blocks to handle this error.";
ErrorMessages["IE_0012"] = "[IE-0012] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/browser\", then run \"CloudSDK().initialize()\".";
ErrorMessages["IE_0013"] = "[IE-0013] - You must first initialize the Cloud SDK. Import \"CloudSDK\" from \"@sitecore-cloudsdk/core/server\", then run \"await CloudSDK().initialize()\".";
ErrorMessages["IV_0001"] = "[IV-0001] Incorrect value for \"sitecoreEdgeUrl\". Set the value to a valid URL string.";

@@ -19,0 +22,0 @@ ErrorMessages["MV_0001"] = "[MV-0001] \"sitecoreEdgeContextId\" is required.";

// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { createCookieString, getCookie } from '@sitecore-cloudsdk/utils';
import { fetchBrowserIdFromEdgeProxy } from '../init/fetch-browser-id-from-edge-proxy';
import { fetchBrowserIdFromEdgeProxy } from '../browser-id/fetch-browser-id-from-edge-proxy';
import { getGuestId } from '../init/get-guest-id';
import { getDefaultCookieAttributes } from './get-default-cookie-attributes';
import { getGuestId } from '../init/get-guest-id';
/**

@@ -7,0 +7,0 @@ * Creates and adds the cookie to the document

@@ -1,6 +0,5 @@

// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { createCookieString, getCookieServerSide } from '@sitecore-cloudsdk/utils';
import { fetchBrowserIdFromEdgeProxy } from '../init/fetch-browser-id-from-edge-proxy';
import { fetchBrowserIdFromEdgeProxy } from '../browser-id/fetch-browser-id-from-edge-proxy';
import { getGuestId } from '../init/get-guest-id';
import { getDefaultCookieAttributes } from './get-default-cookie-attributes';
import { getGuestId } from '../init/get-guest-id';
/**

@@ -7,0 +6,0 @@ * Handles HTTP Cookie operations for setting the browser ID cookie in the request and response.

@@ -1,6 +0,5 @@

// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
import { fetchBrowserIdFromEdgeProxy } from '../init/fetch-browser-id-from-edge-proxy';
import { fetchBrowserIdFromEdgeProxy } from '../browser-id/fetch-browser-id-from-edge-proxy';
import { getGuestId } from '../init/get-guest-id';
import { getCookieValueFromMiddlewareRequest } from './get-cookie-value-from-middleware-request';
import { getDefaultCookieAttributes } from './get-default-cookie-attributes';
import { getGuestId } from '../init/get-guest-id';
/**

@@ -7,0 +6,0 @@ * Handles the Middleware Request and sets a cookie with the provided 'cookieName' and 'cookieValue'.

@@ -12,2 +12,3 @@ import type { Request, Response } from '@sitecore-cloudsdk/utils';

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/

@@ -14,0 +15,0 @@ export declare function getSettingsServer(): Settings;

@@ -16,2 +16,3 @@ // © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.

}
/* eslint-disable max-len */
/**

@@ -25,3 +26,5 @@ * Initializes the core settings for browser-based applications.

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/
/* eslint-enable max-len */
export function getSettingsServer() {

@@ -28,0 +31,0 @@ if (!coreSettings)

@@ -20,2 +20,3 @@ import type { BrowserSettings, Settings } from '../settings/interfaces';

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/

@@ -28,1 +29,15 @@ export declare function initCore(settingsInput: BrowserSettings): Promise<void>;

export declare function setCookiePromise(promise: Promise<void>): void;
interface Engage {
[key: string]: any;
getBrowserId?: () => string;
versions?: {
personalize?: string | undefined;
events?: string | undefined;
};
}
declare global {
interface Window {
Engage: Engage;
}
}
export {};

@@ -27,2 +27,3 @@ import { CORE_NAMESPACE } from '../debug/namespaces';

let createCookiesPromise = null;
/* eslint-disable max-len */
/**

@@ -36,3 +37,5 @@ * Initializes the core settings for browser-based applications.

* @returns A Promise that resolves when initialization is complete.
* @deprecated Cloud SDK v0.4 introduces a new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code.The v0.3 initialization logic is now deprecated and will be removed in a future Cloud SDK release.
*/
/* eslint-enable max-len */
export async function initCore(settingsInput) {

@@ -39,0 +42,0 @@ debug(CORE_NAMESPACE)('coreClient library initialized');

{
"name": "@sitecore-cloudsdk/core",
"version": "0.3.1",
"version": "0.4.0-rc.0",
"license": "Apache-2.0",
"main": "dist/cjs/src/index.js",
"module": "dist/esm/src/index.js",
"types": "dist/esm/src/index.d.ts",
"exports": {
".": {
"types": {
"require": "./dist/cjs/src/index.d.ts",
"default": "./dist/esm/src/index.d.ts"
},
"import": "./dist/esm/src/index.js",
"require": "./dist/cjs/src/index.js"
"./browser": {
"import": "./browser.js",
"require": "./browser.cjs",
"types": "./browser.d.ts"
},
"./server": {
"import": "./server.js",
"require": "./server.cjs",
"types": "./server.d.ts"
},
"./internal": {
"types": "./internal.d.ts",
"import": "./internal.js",
"require": "./internal.js"
}
},
"dependencies": {
"@sitecore-cloudsdk/utils": "^0.3.1",
"@sitecore-cloudsdk/utils": "^0.4.0-rc.0",
"debug": "^4.3.4"

@@ -29,3 +33,12 @@ },

"dist",
"README.md"
"README.md",
"browser.js",
"browser.cjs",
"browser.d.ts",
"server.js",
"server.cjs",
"server.d.ts",
"internal.js",
"internal.cjs",
"internal.d.ts"
],

@@ -32,0 +45,0 @@ "engines": {

# core
This is an internal package used by other Sitecore Cloud SDK packages.
This package is for initializing the Cloud SDK and its other packages in your app.
## Installation
```bash
npm install @sitecore-cloudsdk/core
```
To initialize other Cloud SDK packages, first install them:
```bash
npm install @sitecore-cloudsdk/events
npm install @sitecore-cloudsdk/personalize
```
## Usage
1. Import the modules of all installed Cloud SDK packages that you want to initialize.
2. Initialize the Cloud SDK and its packages using the `CloudSDK` function, available in the `core` package.
## Code examples
Initialize the Cloud SDK and its packages on the browser side:
```tsx
'use client';
import { useEffect } from 'react';
import { CloudSDK } from '@sitecore-cloudsdk/core/browser';
import '@sitecore-cloudsdk/events/browser';
import '@sitecore-cloudsdk/personalize/browser';
export default function Home() {
useEffect(() => {
CloudSDK({
sitecoreEdgeContextId: '<YOUR_CONTEXT_ID>',
siteName: '<YOUR_SITE_NAME>',
enableBrowserCookie: true
})
.addEvents() // Initialize the `events` package.
.addPersonalize({ enablePersonalizeCookie: true, webPersonalization: true }) // Initialize the `personalize` package and enable web personalization.
.initialize();
}, []);
return <></>;
}
```
Initialize the Cloud SDK and its packages on the server side:
```ts
import type { NextRequest, NextResponse } from 'next/server';
import { CloudSDK } from '@sitecore-cloudsdk/core/server';
import '@sitecore-cloudsdk/events/browser';
import '@sitecore-cloudsdk/personalize/browser';
export async function middleware(request: NextRequest) {
const response = NextResponse.next();
await CloudSDK(request, response, {
sitecoreEdgeContextId: '<YOUR_CONTEXT_ID>',
siteName: '<YOUR_SITE_NAME>',
enableServerCookie: true
})
.addEvents() // Initialize the `events` package.
.addPersonalize({ enablePersonalizeCookie: true }) // Initialize the `personalize` package.
.initialize();
return response;
}
```
## Documentation
[Official Sitecore Cloud SDK documentation](https://doc.sitecore.com/xmc/en/developers/sdk/latest/cloud-sdk/index.html)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc