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

@netlify/functions

Package Overview
Dependencies
Maintainers
16
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/functions - npm Package Compare versions

Comparing version 1.1.0-rc to 1.1.0

1

dist/function/event.d.ts

@@ -24,3 +24,4 @@ interface EventHeaders {

isBase64Encoded: boolean;
netlifyGraphToken: string | undefined;
}
export {};

2

dist/function/index.d.ts

@@ -5,3 +5,3 @@ export { Context as HandlerContext } from './context';

export { Response as HandlerResponse } from './response';
export { getSecrets, withSecrets, getNetlifyGraphToken, GraphTokenResponse, HasHeaders } from '../lib/graph';
export { getSecrets, getSecretsForBuild, withSecrets, getNetlifyGraphToken, getNetlifyGraphTokenForBuild, GraphTokenResponse, HasHeaders, } from '../lib/graph';
export { NetlifySecrets } from '../lib/secrets_helper';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNetlifyGraphToken = exports.withSecrets = exports.getSecrets = void 0;
exports.getNetlifyGraphTokenForBuild = exports.getNetlifyGraphToken = exports.withSecrets = exports.getSecretsForBuild = exports.getSecrets = void 0;
var graph_1 = require("../lib/graph");
Object.defineProperty(exports, "getSecrets", { enumerable: true, get: function () { return graph_1.getSecrets; } });
Object.defineProperty(exports, "getSecretsForBuild", { enumerable: true, get: function () { return graph_1.getSecretsForBuild; } });
Object.defineProperty(exports, "withSecrets", { enumerable: true, get: function () { return graph_1.withSecrets; } });
Object.defineProperty(exports, "getNetlifyGraphToken", { enumerable: true, get: function () { return graph_1.getNetlifyGraphToken; } });
Object.defineProperty(exports, "getNetlifyGraphTokenForBuild", { enumerable: true, get: function () { return graph_1.getNetlifyGraphTokenForBuild; } });

@@ -18,3 +18,4 @@ export declare type GraphTokenResponseError = {

}
export declare const getNetlifyGraphToken: (event?: HasHeaders | null | undefined, supressLog?: boolean | undefined) => GraphTokenResponse;
export declare const getNetlifyGraphToken: (event?: HasHeaders | null | undefined, supressLog?: boolean) => GraphTokenResponse;
export declare const getNetlifyGraphTokenForBuild: () => GraphTokenResponse;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNetlifyGraphToken = void 0;
exports.getNetlifyGraphTokenForBuild = exports.getNetlifyGraphToken = void 0;
var process_1 = require("process");
var TOKEN_HEADER = 'X-Nf-Graph-Token';
var TOKEN_HEADER_NORMALIZED = 'x-nf-graph-token';
var hasRequestStyleHeaders = function (headers) {

@@ -10,15 +11,29 @@ return headers.get !== undefined && typeof headers.get === 'function';

var graphTokenFromIncomingHttpStyleHeaders = function (headers) {
if (TOKEN_HEADER in headers) {
var header = headers[TOKEN_HEADER];
if (header == null || typeof header === 'string') {
return header;
if (TOKEN_HEADER in headers || TOKEN_HEADER_NORMALIZED in headers) {
var header = headers[TOKEN_HEADER] || headers[TOKEN_HEADER_NORMALIZED];
if (Array.isArray(header)) {
return header[0];
}
return header[0];
return header;
}
};
// Backwards compatibility with older version of cli that doesn't inject header
var authlifyTokenFallback = function (event) {
var token = event === null || event === void 0 ? void 0 : event.authlifyToken;
var graphTokenFromEnv = function () {
// _NETLIFY_GRAPH_TOKEN injected by next plugin
// eslint-disable-next-line no-underscore-dangle
var token = process_1.env._NETLIFY_GRAPH_TOKEN || process_1.env.NETLIFY_GRAPH_TOKEN;
return { token: token };
};
var tokenFallback = function (event) {
// Backwards compatibility with older version of cli that doesn't inject header
var token = event === null || event === void 0 ? void 0 : event.authlifyToken;
if (token) {
return { token: token };
}
// If we're in dev-mode with next.js, the plugin won't be there to inject
// secrets, so we need to get the token from the environment
if (process_1.env.NETLIFY_DEV === 'true') {
return graphTokenFromEnv();
}
return { token: null };
};
var graphTokenFromEvent = function (event) {

@@ -34,10 +49,4 @@ var headers = event.headers;

}
return authlifyTokenFallback(event);
return tokenFallback(event);
};
var graphTokenFromEnv = function () {
// _NETLIFY_GRAPH_TOKEN injected by next plugin
// eslint-disable-next-line no-underscore-dangle
var token = process_1.env._NETLIFY_GRAPH_TOKEN || process_1.env.NETLIFY_GRAPH_TOKEN;
return { token: token };
};
var isEventRequired = function () {

@@ -86,1 +95,5 @@ var localDev = process_1.env.NETLIFY_DEV === 'true';

exports.getNetlifyGraphToken = getNetlifyGraphToken;
var getNetlifyGraphTokenForBuild = function () {
return graphTokenFromEnv();
};
exports.getNetlifyGraphTokenForBuild = getNetlifyGraphTokenForBuild;

@@ -6,4 +6,4 @@ import { Context as HandlerContext, Context } from '../function/context';

import { NetlifySecrets } from './secrets_helper';
export { getSecrets } from './secrets_helper';
export { getNetlifyGraphToken, GraphTokenResponse, HasHeaders } from './graph_token';
export { getSecrets, getSecretsForBuild } from './secrets_helper';
export { getNetlifyGraphToken, getNetlifyGraphTokenForBuild, GraphTokenResponse, HasHeaders } from './graph_token';
export interface ContextWithSecrets extends Context {

@@ -10,0 +10,0 @@ secrets: NetlifySecrets;

@@ -50,3 +50,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.withSecrets = exports.getNetlifyGraphToken = exports.getSecrets = void 0;
exports.withSecrets = exports.getNetlifyGraphTokenForBuild = exports.getNetlifyGraphToken = exports.getSecretsForBuild = exports.getSecrets = void 0;
var secrets_helper_1 = require("./secrets_helper");

@@ -56,4 +56,6 @@ // Fine-grained control during the preview, less necessary with a more proactive OneGraph solution

Object.defineProperty(exports, "getSecrets", { enumerable: true, get: function () { return secrets_helper_2.getSecrets; } });
Object.defineProperty(exports, "getSecretsForBuild", { enumerable: true, get: function () { return secrets_helper_2.getSecretsForBuild; } });
var graph_token_1 = require("./graph_token");
Object.defineProperty(exports, "getNetlifyGraphToken", { enumerable: true, get: function () { return graph_token_1.getNetlifyGraphToken; } });
Object.defineProperty(exports, "getNetlifyGraphTokenForBuild", { enumerable: true, get: function () { return graph_token_1.getNetlifyGraphTokenForBuild; } });
// The common usage of this module

@@ -60,0 +62,0 @@ var withSecrets = function (handler) {

@@ -35,2 +35,3 @@ import { HasHeaders } from './graph_token';

export declare const getSecrets: (event?: HasHeaders | null | undefined) => Promise<NetlifySecrets>;
export declare const getSecretsForBuild: () => Promise<NetlifySecrets>;
export {};

@@ -50,3 +50,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getSecrets = void 0;
exports.getSecretsForBuild = exports.getSecrets = void 0;
var graph_request_1 = require("./graph_request");

@@ -106,6 +106,24 @@ var graph_token_1 = require("./graph_token");

};
// Note: We may want to have configurable "sets" of secrets,
// e.g. "dev" and "prod"
// We select for more than we typically need here
// in order to allow for some metaprogramming for
// consumers downstream. Also, the data is typically
// static and shouldn't add any measurable overhead.
var findLoggedInServicesQuery = "query FindLoggedInServicesQuery {\n me {\n serviceMetadata {\n loggedInServices {\n friendlyServiceName\n service\n isLoggedIn\n bearerToken\n grantedScopes {\n scope\n scopeInfo {\n category\n scope\n display\n isDefault\n isRequired\n description\n title\n }\n }\n }\n }\n }\n }";
var getSecretsForToken = function (token) { return __awaiter(void 0, void 0, void 0, function () {
var body, resultBody, result, newSecrets;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = JSON.stringify({ query: findLoggedInServicesQuery });
return [4 /*yield*/, (0, graph_request_1.graphRequest)(token, new TextEncoder().encode(body))];
case 1:
resultBody = _a.sent();
result = JSON.parse(resultBody);
newSecrets = formatSecrets(result);
return [2 /*return*/, newSecrets];
}
});
}); };
var getSecrets = function (event) { return __awaiter(void 0, void 0, void 0, function () {
var graphTokenResponse, graphToken, doc, body, resultBody, result, newSecrets;
var graphTokenResponse, graphToken;
return __generator(this, function (_a) {

@@ -122,10 +140,4 @@ switch (_a.label) {

}
doc = "query FindLoggedInServicesQuery {\n me {\n serviceMetadata {\n loggedInServices {\n friendlyServiceName\n service\n isLoggedIn\n bearerToken\n grantedScopes {\n scope\n scopeInfo {\n category\n scope\n display\n isDefault\n isRequired\n description\n title\n }\n }\n }\n }\n }\n }";
body = JSON.stringify({ query: doc });
return [4 /*yield*/, (0, graph_request_1.graphRequest)(graphToken, new TextEncoder().encode(body))];
case 1:
resultBody = _a.sent();
result = JSON.parse(resultBody);
newSecrets = formatSecrets(result);
return [2 /*return*/, newSecrets];
return [4 /*yield*/, getSecretsForToken(graphToken)];
case 1: return [2 /*return*/, _a.sent()];
}

@@ -135,1 +147,20 @@ });

exports.getSecrets = getSecrets;
var getSecretsForBuild = function () { return __awaiter(void 0, void 0, void 0, function () {
var graphTokenResponse, graphToken;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
graphTokenResponse = (0, graph_token_1.getNetlifyGraphTokenForBuild)();
graphToken = graphTokenResponse.token;
if (!graphToken) {
if (graphTokenResponse.errors) {
logErrors(graphTokenResponse.errors);
}
return [2 /*return*/, {}];
}
return [4 /*yield*/, getSecretsForToken(graphToken)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); };
exports.getSecretsForBuild = getSecretsForBuild;

@@ -5,3 +5,3 @@ {

"types": "./dist/main.d.ts",
"version": "1.1.0-rc",
"version": "1.1.0",
"description": "JavaScript utilities for Netlify Functions",

@@ -8,0 +8,0 @@ "files": [

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