Gathering detailed insights and metrics for @trustedshops-public/cot-integration-library
Gathering detailed insights and metrics for @trustedshops-public/cot-integration-library
A JavaScript/Typescript integration library for connecting to Community of Trust platform.
npm install @trustedshops-public/cot-integration-library
Typescript
Module System
Node Version
NPM Version
TypeScript (96.56%)
HTML (1.63%)
CSS (1.11%)
JavaScript (0.7%)
Total Downloads
446
Last Day
2
Last Week
40
Last Month
446
Last Year
446
97 Commits
3 Branches
4 Contributors
Latest Version
1.9.1
Package Id
@trustedshops-public/cot-integration-library@1.9.1
Unpacked Size
6.75 MB
Size
1.59 MB
File Count
10
NPM Version
10.1.0
Node Version
20.9.0
Publised On
04 Feb 2025
Cumulative downloads
Total Downloads
Last day
-99.3%
2
Compared to previous day
Last week
-90.1%
40
Compared to previous week
Last month
0%
446
Compared to previous month
Last year
0%
446
Compared to previous year
4
23
This library provides a comprehensive JavaScript/Typescript interface for integrating with the Community of Trust (COT) platform, facilitating seamless interactions with its services.
To install the library, run the following command in your project directory:
1npm i @trustedshops-public/cot-integration-library
Here is a basic example of how to use the library:
On the backend side:
1import { Client } from '@trustedshops-public/cot-integration-library'; 2 3// Initialize the client with the required parameters once 4const client = new Client( 5 <TSID>, // Trusted Shops ID - e.g. 'X1234567890123456789012345678901' 6 <CLIENT_ID>, // Client ID - e.g. 'cot-switch-X1234567890123456789012345678901' 7 <CLIENT_SECRET>, // Client Secret - e.g. '1234567890123456789012345678901234567890123456789012345678901234' 8 <AUTH_STORAGE_INSTANCE>, // It can be any storage option implementing AuthStorageInterface - e.g. new DatabaseAuthStorage() 9 <ENV> // Environment (optional) - dev, test, or prod, defaults to prod 10); 11 12// Set the cookie handler to handle cookies everytime before a request is made and handled 13client.setCookieHandler(<COOKIE_HANDLER_INSTANCE>); 14 15// Pass the actual url which the authentication has been started from to let authentication server verify the redirect uri e.g. 'https://www.example.com/shop' 16client.setRedirectUri(<REDIRECT_URI>); 17 18// Invoke handleCallback function to handle code coming from the authentication server 19await client.handleCallback(authCode); 20 21// Get anonymous consumer data for the current user 22const consumerData = await client.getAnonymousConsumerData();
On the frontend side, place the following code in your HTML file where you want the widget to appear:
1<trstd-switch tsId="X1234567890123456789012345678901"></trstd-switch> 2<script type="module" src="https://widgets.trustedshops.com/switch/switch.js"></script>
For more detailed examples, please refer to the examples/
directory.
To get started with development, clone the repository and install the dependencies:
1npm i
Setup the environment variables:
1cp .env.example .env.local
and fill in the required values.
Hint: You can use this environment variable for local testing of examples. Copy
.env.example
to.env
and fill in the required values in the root directory of the example, e.g.,shopify-integration
.
Generate local ssl certificates:
1npm run generate-ssl-cert
To run local development server, use the following command:
1npm run dev
To run the tests, use the following command:
1npm test
To build the library, use the following command:
1npm run build
Contributions are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
This library is licensed under the MIT License - see the LICENSE file for details.
This project relies on several open-source libraries that have made development easier and more efficient. We would like to acknowledge the following libraries:
We are grateful to the developers and maintainers of these projects for their hard work and dedication.
This project adheres to Semantic Versioning. For the versions available, see the tags on this repository.
No vulnerabilities found.
No security vulnerabilities found.