Gathering detailed insights and metrics for @rudderstack/analytics-js-cookies
Gathering detailed insights and metrics for @rudderstack/analytics-js-cookies
Gathering detailed insights and metrics for @rudderstack/analytics-js-cookies
Gathering detailed insights and metrics for @rudderstack/analytics-js-cookies
npm install @rudderstack/analytics-js-cookies
Typescript
Module System
Node Version
NPM Version
74.5
Supply Chain
98.9
Quality
97.6
Maintenance
100
Vulnerability
93.6
License
rudderstack/analytics-js-service-worker@3.2.17
Published on 17 Dec 2024
@rudderstack/analytics-js-integrations@3.11.14
Published on 17 Dec 2024
@rudderstack/analytics-js-loading-scripts@3.0.59
Published on 17 Dec 2024
rudder-sdk-js@2.48.42
Published on 17 Dec 2024
@rudderstack/analytics-js@3.11.16
Published on 17 Dec 2024
@rudderstack/analytics-js-plugins@3.6.20
Published on 17 Dec 2024
TypeScript (48.61%)
JavaScript (44.44%)
HTML (6.7%)
Shell (0.24%)
Total Downloads
10,488
Last Day
19
Last Week
365
Last Month
2,290
Last Year
10,488
145 Stars
4,074 Commits
83 Forks
13 Watching
18 Branches
88 Contributors
Minified
Minified + Gzipped
Latest Version
0.4.17
Package Id
@rudderstack/analytics-js-cookies@0.4.17
Unpacked Size
79.20 kB
Size
13.91 kB
File Count
12
NPM Version
10.2.4
Node Version
20.11.1
Publised On
17 Dec 2024
Cumulative downloads
Total Downloads
Last day
-78.7%
19
Compared to previous day
Last week
-15.1%
365
Compared to previous week
Last month
-29%
2,290
Compared to previous month
Last year
0%
10,488
Compared to previous year
No dependencies detected.
The Customer Data Platform for Developers
Website · Documentation · Community Slack
RudderStack JavaScript SDK utilities for cookies in browser and Node.js environments. Use the appropriate functions for your environment.
getDecryptedValueBrowser
:warning: Only for browser environments
This function decrypts the provided encrypted RudderStack JavaScript cookie value using the RudderStack JavaScript SDK encryption version "v3".
If the provided value is either not encrypted or not properly encrypted, the function returns
null
.
:warning: Any errors during decryption are swallowed by the function, returning
null
.
1import { getDecryptedValueBrowser } from '@rudderstack/analytics-js-cookies'; 2 3const encryptedCookieValue = 'RS_ENC_v3_InRlc3QtZGF0YSI='; 4const decryptedCookieValue = getDecryptedValueBrowser(encryptedCookieValue); 5console.log('Decrypted Cookie Value: ', decryptedCookieValue); 6// Output: 7// Decrypted Cookie Value: test-data
getDecryptedValue
:warning: Only for Node.js environments
This function decrypts the provided encrypted RudderStack JavaScript cookie value using the RudderStack JavaScript SDK encryption version "v3".
If the provided value is either not encrypted or not properly encrypted, the function returns
null
.
:warning: Any errors during decryption are swallowed by the function, returning
null
.
1import { getDecryptedValue } from '@rudderstack/analytics-js-cookies'; 2 3const encryptedCookieValue = 'RS_ENC_v3_InRlc3QtZGF0YSI='; 4const decryptedCookieValue = getDecryptedValue(encryptedCookieValue); 5console.log('Decrypted Cookie Value: ', decryptedCookieValue); 6// Output: 7// Decrypted Cookie Value: test-data
getDecryptedCookieBrowser
:warning: Only for browser environments
This function takes the name of the RudderStack JavaScript SDK cookie and returns the decrypted value.
The return type is either a string
or an object
as some cookies like user ID, anonymous user ID have string values while user traits are objects.
It returns null
in either of the following scenarios:
:warning: Any errors during decryption are swallowed by the function, returning
null
.
The following cookie keys are exported which can be used with this function:
userIdKey
: The key for the user ID cookie.userTraitsKey
: The key for the user traits cookie.anonymousUserIdKey
: The key for the anonymous user ID cookie.groupIdKey
: The key for the group ID cookie.groupTraitsKey
: The key for the group traits cookie.pageInitialReferrerKey
: The key for the page initial referrer cookie.pageInitialReferringDomainKey
: The key for the page initial referring domain cookie.sessionInfoKey
: The key for the session ID cookie.authTokenKey
: The key for the auth token cookie.1import { 2 getDecryptedCookieBrowser, 3 anonymousUserIdKey, 4 userTraitsKey, 5} from '@rudderstack/analytics-js-cookies'; 6 7const anonymousId = getDecryptedCookieBrowser(anonymousUserIdKey); 8console.log('Anonymous User ID: ', anonymousId); 9// Output: 10// Anonymous User ID: 2c5b6d48-ea90-43a2-a2f6-457d27f90328 11 12const userTraits = getDecryptedCookieBrowser(userTraitsKey); 13console.log('User Traits: ', userTraits); 14// Output: 15// User Traits: {"email":"abc@xyz.com","name":"John Doe"} 16 17const invalidCookie = getDecryptedCookieBrowser('invalid-cookie-name'); 18console.log('Invalid Cookie: ', invalidCookie); 19// Output: 20// Invalid Cookie: null
As all the above APIs swallow the errors, you can set the debug
argument to true
to log the errors.
1import { getDecryptedValue } from '@rudderstack/analytics-js-cookies'; 2 3const encryptedCookieValue = 'RS_ENC_v3_InRlc3QtZGF0YSI-some-random-data'; 4 5// Set the debug flag to true 6const decryptedCookieValue = getDecryptedValue(encryptedCookieValue, true); 7console.log('Decrypted Cookie Value: ', decryptedCookieValue); 8 9// Output: 10// Error occurred during decryption: Unexpected non-whitespace character after JSON at position 11 11// Decrypted Cookie Value: null
This project is licensed under the Elastic License 2.0. See the LICENSE.md file for details. Review the license terms to understand your permissions and restrictions.
If you have any questions about licensing, please contact us or refer to the official Elastic licensing page.
We invite you to contribute to this project. For more information on how to contribute, please see here.
For more information on any of the sections covered in this readme, you can contact us or start a conversation on our Slack channel.
No vulnerabilities found.
Reason
30 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 3/13 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More