Skip to content

Commit 2112561

Browse files
authored
Merge pull request #123 from contentstack/fix/MKT-8046
Fix/mkt 8046 : Added sub resource integrity hash
2 parents faecf68 + 387b0f5 commit 2112561

File tree

7 files changed

+5559
-5327
lines changed

7 files changed

+5559
-5327
lines changed

.github/readme/blueprint.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Contentstack App SDK Readme
2+
The Contentstack App SDK allows you to customize your applications. This document will help you integrate the App SDK with your application.
3+
4+
Getting started
5+
6+
Include the compiled version of the extension client library by adding the following line to your application.
7+
8+
<script
9+
src="https://unpkg.com/@contentstack/app-sdk@{{pkg.version}}/dist/index.js"
10+
integrity="{{subresourceIntegrity.js}}"
11+
crossorigin="anonymous"
12+
></script>
13+
14+
To include the App SDK in your project, you need to run the following command:
15+
16+
npm install @contentstack/app-sdk
17+
Alternatively, you can use the following command within the script tag to install the App SDK:
18+
19+
<script src="https://unpkg.com/@contentstack/[email protected]/dist/index.js"></script>
20+
21+
Initializing the App SDK
22+
To Initialize the App SDK you need to run the following command:
23+
24+
ContentstackAppSdk.init().then(function (appSdk) {
25+
// add code here
26+
});
27+
For more information, please refer to our App SDK API Reference document.
28+
29+
Download the Boilerplate
30+
You can extend or customize the functionality of Contentstack CMS with Marketplace apps. To simplify and speed up the building process, boilerplates describe repetitive elements in a project. This boilerplate will help you build custom applications for your organization or stack.
31+
32+
Download the boilerplate.
33+
34+
UI Locations and Examples
35+
UI Locations allow you to extend Contentstack's functionality. Through these UI locations, you can customize Contentstack's default behavior and UI. Integration of third-party applications is possible using different UI locations.
36+
37+
The Contentstack App SDK currently supports the following UI Locations:
38+
39+
Custom Field Location
40+
Dashboard Location
41+
Asset Sidebar Location
42+
App Config Location
43+
RTE Location
44+
Sidebar Location
45+
Field Modifier Location
46+
Full Page Location
47+
Custom Field Location
48+
Custom Field Location allows you to create custom fields that can be used in your content types. You can integrate with various business applications, such as Bynder, Cloudinary, Shopify, by adding them as a custom field to your stack's content type.
49+
50+
Dashboard Location
51+
With the Dashboard Location, you can create widgets for your stack dashboard. Integration with Google Analytics provides meaningful insights about your website.
52+
53+
Asset Sidebar Location
54+
Using the Asset Sidebar Location, you can create customized sidebar widgets to extend the functionality of your assets.
55+
56+
Manage, transform, and optimize your stack's assets efficiently using the Image Preset Builder.
57+
58+
App Config Location
59+
App Config UI Location allows you to manage all the app settings centrally. Once configured, all other locations (where the app is installed) can access these settings.
60+
61+
RTE Location
62+
The RTE Location allows you to create custom plugins to expand the functionality of your JSON Rich Text Editor. Using the Audience and Variables plugin, you can tailor your content as per your requirements.
63+
64+
Sidebar Location
65+
The Sidebar Location provides powerful tools for analyzing and recommending ideas for your entry. Use the Smartling sidebar location to help translate your content.
66+
67+
Field Modifier Location
68+
The Field Modifier Location is a type of UI location which extends the capabilities of entry fields. With the Field Modifier UI location, you can allow the different apps to appear on defined field data types such as Text, Number, JSON, Boolean, File, Reference fields etc.
69+
70+
Full Page Location
71+
The Full Page location is a type of UI location that lets you view full page apps such as Release Preview within your stack.
72+
73+
Using Contentstack styles
74+
Install the Venus UI library package to style your app according to the Contentstack UI:
75+
76+
npm i @contentstack/venus-components --save
77+
For more information on styling your application, refer to our style guide.
78+
79+
More information
80+
App SDK API Reference
81+
Marketplace Platform Guides
82+
Marketplace Apps
83+
Contentstack App Development
84+
App SDK v2.0.0 Migration Guide
85+
This guide provides instructions for migrating your application to App SDK version 2.0.0. It covers changes in metadata responses, field modifier and full page location updates, and the transition from the \_extension property to \_uiLocation. If you are upgrading your app to the latest version, make sure to follow these steps for a smooth transition.
86+
87+
Read the Migration Guide
88+
89+
License
90+
Licensed under MIT.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ The Contentstack App SDK allows you to customize your applications. This documen
44

55
## Getting started
66

7+
Include the compiled version of the extension client library by adding the following line to your application.
8+
9+
<script
10+
src="https://unpkg.com/@contentstack/[email protected]/dist/index.js"
11+
integrity="sha512-wlEBUkZA+vdcHXRTK69fZvK44c5Y8KeU/kw9OOShWNDjddtrIB8a1lfbLjH5nKWQqkWZ2L9VYEqr96P7qx3ZZg=="
12+
crossorigin="anonymous"
13+
></script>
14+
715
To include the App SDK in your project, you need to run the following command:
816

917
```sh

blueprint.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"input": "./.github/readme/blueprint.md",
3+
"headingPrefix": {
4+
"1": "",
5+
"2": ""
6+
},
7+
"line": "none",
8+
"subresourceIntegrity": {
9+
"js": "sha512-wlEBUkZA+vdcHXRTK69fZvK44c5Y8KeU/kw9OOShWNDjddtrIB8a1lfbLjH5nKWQqkWZ2L9VYEqr96P7qx3ZZg=="
10+
}
11+
}

package-lock.json

Lines changed: 71 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"prettier:fix": "npx prettier src --write",
1919
"lint:fix": "eslint --fix",
2020
"prepare": "npm run build && husky install",
21-
"format": "npm run prettier:fix && npm run lint:fix"
21+
"format": "npm run prettier:fix && npm run lint:fix",
22+
"generate:sri": "node ./subresourceIntegrity.js",
23+
"generate:readme": "npm run build && npm run generate:sri && npx @appnest/readme generate"
2224
},
2325
"keywords": [],
2426
"author": {
@@ -56,8 +58,10 @@
5658
"webpack-dev-server": "^4.7.3"
5759
},
5860
"dependencies": {
61+
"jsonfile": "^6.1.0",
5962
"loader-utils": "^3.2.1",
6063
"post-robot": "^8.0.31",
64+
"ssri": "^12.0.0",
6165
"wolfy87-eventemitter": "^5.2.9"
6266
},
6367
"files": [

subresourceIntegrity.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const ssri = require("ssri");
2+
const fs = require("fs");
3+
const jsonfile = require("jsonfile");
4+
5+
async function generateSRI() {
6+
const blueprintPath = "./blueprint.json";
7+
8+
const sriJS = await ssri.fromStream(
9+
fs.createReadStream("./dist/index.js")
10+
);
11+
12+
let blueprint = {};
13+
if (fs.existsSync(blueprintPath) && fs.statSync(blueprintPath).size > 0) {
14+
blueprint = JSON.parse(fs.readFileSync(blueprintPath));
15+
}
16+
17+
blueprint.subresourceIntegrity = {
18+
js: sriJS.toString()
19+
};
20+
21+
jsonfile.writeFile(blueprintPath, blueprint, { spaces: 2 });
22+
}
23+
24+
generateSRI();

0 commit comments

Comments
 (0)