Initial Save

This commit is contained in:
jackbeeby
2025-03-28 12:30:19 +11:00
parent e381994f19
commit d8773925e8
9910 changed files with 982718 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# @apollographql/graphql-playground-html
**NOTE:** This is a fork of [`graphql-playground-html`](https://npm.im/graphql-playground-html) which is meant to be used by Apollo Server and only by Apollo Server. It is not intended to be used directly. Those looking to use GraphQL Playground directly can refer to [the upstream repository](https://github.com/prisma-labs/graphql-playground) for usage instructions.
> **SECURITY WARNING:** Via the upstream fork, this package had a severe XSS Reflection attack vulnerability until version `1.6.25` of this package. **While we have published a fix, users were only affected if they were using `@apollographql/graphql-playground-html` directly as their own custom middleware.** The direct usage of this package was never recommended as it provided no advantage over the upstream package in that regard. Users of Apollo Server who leverage this package automatically by the dependency declared within Apollo Sever were not affected since Apollo Server never provided dynamic facilities to customize playground options per request. Users of Apollo Server would have had to statically embedded very explicit vulnerabilities (e.g., using malicious, unescaped code, `<script>` tags, etc.).

View File

@@ -0,0 +1,5 @@
declare const getLoadingMarkup: () => {
script: string;
container: string;
};
export default getLoadingMarkup;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-loading-markup.js","sourceRoot":"","sources":["../src/get-loading-markup.ts"],"names":[],"mappings":";;AAAA,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IAC9B,MAAM,EAAE,kKAKL;IACH,SAAS,EAAE,wofA4cZ;CACA,CAAC,EApd6B,CAod7B,CAAA;AAEF,kBAAe,gBAAgB,CAAA"}

View File

@@ -0,0 +1 @@
export { renderPlaygroundPage, MiddlewareOptions, RenderPageOptions, } from './render-playground-page';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var render_playground_page_1 = require("./render-playground-page");
Object.defineProperty(exports, "renderPlaygroundPage", { enumerable: true, get: function () { return render_playground_page_1.renderPlaygroundPage; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,mEAIiC;AAH/B,8HAAA,oBAAoB,OAAA"}

View File

@@ -0,0 +1,71 @@
export interface MiddlewareOptions {
endpoint?: string;
subscriptionEndpoint?: string;
workspaceName?: string;
env?: any;
config?: any;
settings?: ISettings;
schema?: IntrospectionResult;
tabs?: Tab[];
codeTheme?: EditorColours;
}
export declare type CursorShape = 'line' | 'block' | 'underline';
export declare type Theme = 'dark' | 'light';
export interface ISettings {
'general.betaUpdates': boolean;
'editor.cursorShape': CursorShape;
'editor.theme': Theme;
'editor.reuseHeaders': boolean;
'tracing.hideTracingResponse': boolean;
'queryPlan.hideQueryPlanResponse'?: boolean;
'editor.fontSize': number;
'editor.fontFamily': string;
'request.credentials': string;
'schema.polling.enable': boolean;
'schema.polling.endpointFilter': string;
'schema.polling.interval': number;
}
export interface EditorColours {
property: string;
comment: string;
punctuation: string;
keyword: string;
def: string;
qualifier: string;
attribute: string;
number: string;
string: string;
builtin: string;
string2: string;
variable: string;
meta: string;
atom: string;
ws: string;
selection: string;
cursorColor: string;
editorBackground: string;
resultBackground: string;
leftDrawerBackground: string;
rightDrawerBackground: string;
}
export interface IntrospectionResult {
__schema: any;
}
export interface RenderPageOptions extends MiddlewareOptions {
version?: string;
cdnUrl?: string;
env?: any;
title?: string;
faviconUrl?: string | null;
}
export interface Tab {
endpoint: string;
query: string;
name?: string;
variables?: string;
responses?: string[];
headers?: {
[key: string]: string;
};
}
export declare function renderPlaygroundPage(options: RenderPageOptions): string;

View File

@@ -0,0 +1,59 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderPlaygroundPage = void 0;
var xss_1 = require("xss");
var get_loading_markup_1 = require("./get-loading-markup");
var filter = function (val) {
return xss_1.filterXSS(val, {
// @ts-ignore
whiteList: [],
stripIgnoreTag: true,
stripIgnoreTagBody: ["script"]
});
};
var loading = get_loading_markup_1.default();
var reactPackageName = '@apollographql/graphql-playground-react';
var getCdnMarkup = function (_a) {
var version = _a.version, _b = _a.cdnUrl, cdnUrl = _b === void 0 ? '//cdn.jsdelivr.net/npm' : _b, faviconUrl = _a.faviconUrl;
var buildCDNUrl = function (packageName, suffix) { return filter(cdnUrl + "/" + packageName + (version ? "@" + version : '') + "/" + suffix || ''); };
return "\n <link\n rel=\"stylesheet\"\n href=\"" + buildCDNUrl(reactPackageName, 'build/static/css/index.css') + "\"\n />\n " + (typeof faviconUrl === 'string' ? "<link rel=\"shortcut icon\" href=\"" + filter(faviconUrl || '') + "\" />" : '') + "\n " + (faviconUrl === undefined ? "<link rel=\"shortcut icon\" href=\"" + buildCDNUrl(reactPackageName, 'build/favicon.png') + "\" />" : '') + "\n <script\n src=\"" + buildCDNUrl(reactPackageName, 'build/static/js/middleware.js') + "\"\n ></script>\n";
};
var renderConfig = function (config) {
return '<div id="playground-config" style="display: none;">' + xss_1.filterXSS(JSON.stringify(config), {
// @ts-ignore
whiteList: [],
}) + '</div>';
};
function renderPlaygroundPage(options) {
var extendedOptions = __assign(__assign({}, options), { canSaveConfig: false });
// for compatibility
if (options.subscriptionsEndpoint) {
extendedOptions.subscriptionEndpoint = filter(options.subscriptionsEndpoint || '');
}
if (options.config) {
extendedOptions.configString = JSON.stringify(options.config, null, 2);
}
if (!extendedOptions.endpoint && !extendedOptions.configString) {
/* tslint:disable-next-line */
console.warn("WARNING: You didn't provide an endpoint and don't have a .graphqlconfig. Make sure you have at least one of them.");
}
else if (extendedOptions.endpoint) {
extendedOptions.endpoint = filter(extendedOptions.endpoint || '');
}
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=utf-8 />\n <meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui\">\n <link href=\"https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700\" rel=\"stylesheet\">\n <title>" + (filter(extendedOptions.title) || 'GraphQL Playground') + "</title>\n " + (extendedOptions.env === 'react' || extendedOptions.env === 'electron'
? ''
: getCdnMarkup(extendedOptions)) + "\n </head>\n <body>\n <style type=\"text/css\">\n html {\n font-family: \"Open Sans\", sans-serif;\n overflow: hidden;\n }\n \n body {\n margin: 0;\n background: #172a3a;\n }\n \n .playgroundIn {\n -webkit-animation: playgroundIn 0.5s ease-out forwards;\n animation: playgroundIn 0.5s ease-out forwards;\n }\n \n @-webkit-keyframes playgroundIn {\n from {\n opacity: 0;\n -webkit-transform: translateY(10px);\n -ms-transform: translateY(10px);\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n -webkit-transform: translateY(0);\n -ms-transform: translateY(0);\n transform: translateY(0);\n }\n }\n \n @keyframes playgroundIn {\n from {\n opacity: 0;\n -webkit-transform: translateY(10px);\n -ms-transform: translateY(10px);\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n -webkit-transform: translateY(0);\n -ms-transform: translateY(0);\n transform: translateY(0);\n }\n }\n </style>\n " + loading.container + "\n " + renderConfig(extendedOptions) + "\n <div id=\"root\" />\n <script type=\"text/javascript\">\n window.addEventListener('load', function (event) {\n " + loading.script + "\n \n const root = document.getElementById('root');\n root.classList.add('playgroundIn');\n const configText = document.getElementById('playground-config').innerText\n if(configText && configText.length) {\n try {\n GraphQLPlayground.init(root, JSON.parse(configText))\n }\n catch(err) {\n console.error(\"could not find config\")\n }\n }\n })\n </script>\n </body>\n </html>\n";
}
exports.renderPlaygroundPage = renderPlaygroundPage;
//# sourceMappingURL=render-playground-page.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"render-playground-page.js","sourceRoot":"","sources":["../src/render-playground-page.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2BAAgC;AAEhC,2DAAmD;AA6EnD,IAAM,MAAM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AA0B;IAC7D,IAAM,eAAe,yBAChB,OAAO,KACV,aAAa,EAAE,KAAK,GACrB,CAAA;IACD,oBAAoB;IACpB,IAAK,OAAe,CAAC,qBAAqB,EAAE;QAC1C,eAAe,CAAC,oBAAoB,GAAG,MAAM,CAAE,OAAe,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;KAC5F;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;KACvE;IACD,IAAI,CAAC,eAAe,CAAC,QAAQ,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE;QAC9D,8BAA8B;QAC9B,OAAO,CAAC,IAAI,CACV,mHAAmH,CACpH,CAAA;KACF;SACI,IAAI,eAAe,CAAC,QAAQ,EAAE;QACjC,eAAe,CAAC,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;KAClE;IAED,OAAO,wVAOI,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,oBAAoB,wBAE9D,eAAe,CAAC,GAAG,KAAK,OAAO,IAAI,eAAe,CAAC,GAAG,KAAK,UAAU;QACnE,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,qsCAkD/B,OAAO,CAAC,SAAS,cACjB,YAAY,CAAC,eAAe,CAAC,4IAIzB,OAAO,CAAC,MAAM,seAiBvB,CAAA;AACD,CAAC;AA1GD,oDA0GC"}

View File

@@ -0,0 +1,33 @@
{
"name": "@apollographql/graphql-playground-html",
"version": "1.6.27",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-html",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
"Tim Suchanek <tim@graph.cool>",
"Johannes Schickling <johannes@graph.cool>",
"Mohammad Rajabifard <mo.rajbi@gmail.com>"
],
"repository": "http://github.com/graphcool/graphql-playground.git",
"license": "MIT",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"build": "rimraf dist && tsc",
"prepare": "npm run build"
},
"devDependencies": {
"@types/node": "12.12.34",
"rimraf": "3.0.2",
"typescript": "3.9.5"
},
"typings": "dist/index.d.ts",
"typescript": {
"definition": "dist/index.d.ts"
},
"dependencies": {
"xss": "^1.0.8"
}
}