New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inrupt/generate-oidc-token

Package Overview
Dependencies
Maintainers
10
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inrupt/generate-oidc-token - npm Package Compare versions

Comparing version 0.0.1-dependabotgithubactionsactionssetup-node-v214-426655254-10-1608154036.0 to 0.0.1-featinitial-bootstrap-app-426705153-13-1608155778.0

61

dist/index.js
"use strict";
/**
/*
* Copyright 2020 Inrupt Inc.

@@ -22,7 +22,56 @@ *

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.helloWorld = void 0;
function helloWorld() {
return "hello world!";
}
exports.helloWorld = helloWorld;
// The only import we need from the Node AuthN library is the Session class.
const solid_client_authn_node_1 = require("@inrupt/solid-client-authn-node");
const solid_client_authn_core_1 = require("@inrupt/solid-client-authn-core");
const argv = require("yargs/yargs")(process.argv.slice(2))
.describe("oidcIssuer", "The identity provider at which the user should authenticate.")
.alias("issuer", "oidcIssuer")
.describe("clientName", "The name of the bootstrapped app.")
.demandOption(["oidcIssuer"])
.locale("en")
.help().argv;
const express_1 = __importDefault(require("express"));
const app = express_1.default();
const PORT = 3001;
const iriBase = `http://localhost:${PORT}`;
const storage = new solid_client_authn_core_1.InMemoryStorage();
// Initialised when the server comes up and is running...
let session;
const server = app.listen(PORT, async () => {
session = new solid_client_authn_node_1.Session({
insecureStorage: storage,
secureStorage: storage,
});
console.log(`Listening at: [http://localhost:${PORT}].`);
console.log(`Logging in ${argv.oidcIssuer} to get a refresh token.`);
session.login({
clientName: argv.clientName,
oidcIssuer: argv.oidcIssuer,
redirectUrl: iriBase,
tokenType: "DPoP",
handleRedirect: (url) => {
console.log(`\nPlease visit ${url} in a web browser.\n`);
},
});
});
app.get("/", async (_req, res) => {
console.log("Login successful.");
await session.handleIncomingRedirect(`${iriBase}${_req.url}`);
// NB: This is a temporary approach, and we have work planned to properly
// collect the token. Please note that the next line is not part of the public
// API, and is therefore likely to break on non-major changes.
const rawStoredSession = await storage.get(`solidClientAuthenticationUser:${session.info.sessionId}`);
if (rawStoredSession === undefined) {
throw new Error(`Cannot find session with ID [${session.info.sessionId}] in storage.`);
}
const storedSession = JSON.parse(rawStoredSession);
console.log(`\nRefresh token: [${storedSession.refreshToken}]`);
console.log(`Client ID: [${storedSession.clientId}]`);
console.log(`Client Secret: [${storedSession.clientSecret}]`);
res.send("The tokens have been sent to the bootstraping app. You can close this window.");
server.close();
});

10

package.json
{
"name": "@inrupt/generate-oidc-token",
"version": "0.0.1-dependabotgithubactionsactionssetup-node-v214-426655254-10-1608154036.0",
"version": "0.0.1-featinitial-bootstrap-app-426705153-13-1608155778.0",
"description": "A small app to help scripts access private resources on Solid Pods",

@@ -28,2 +28,3 @@ "main": "dist/index.js",

"devDependencies": {
"@types/express": "^4.17.9",
"@types/jest": "^26.0.19",

@@ -51,3 +52,8 @@ "@typescript-eslint/eslint-plugin": "^4.10.0",

},
"dependencies": {}
"dependencies": {
"@inrupt/solid-client-authn-core": "^1.2.2",
"@inrupt/solid-client-authn-node": "^1.2.2",
"express": "^4.17.1",
"yargs": "^16.2.0"
}
}

@@ -1,2 +0,2 @@

/**
/*
* Copyright 2020 Inrupt Inc.

@@ -22,4 +22,65 @@ *

export function helloWorld() {
return "hello world!";
}
// The only import we need from the Node AuthN library is the Session class.
import { Session } from "@inrupt/solid-client-authn-node";
import { InMemoryStorage } from "@inrupt/solid-client-authn-core";
const argv = require("yargs/yargs")(process.argv.slice(2))
.describe("oidcIssuer", "The identity provider at which the user should authenticate.")
.alias("issuer", "oidcIssuer")
.describe("clientName", "The name of the bootstrapped app.")
.demandOption(["oidcIssuer"])
.locale("en")
.help().argv;
import express from "express";
const app = express();
const PORT = 3001;
const iriBase = `http://localhost:${PORT}`;
const storage = new InMemoryStorage();
// Initialised when the server comes up and is running...
let session: Session;
const server = app.listen(PORT, async () => {
session = new Session({
insecureStorage: storage,
secureStorage: storage,
});
console.log(`Listening at: [http://localhost:${PORT}].`);
console.log(`Logging in ${argv.oidcIssuer} to get a refresh token.`);
session.login({
clientName: argv.clientName,
oidcIssuer: argv.oidcIssuer,
redirectUrl: iriBase,
tokenType: "DPoP",
handleRedirect: (url) => {
console.log(`\nPlease visit ${url} in a web browser.\n`);
},
});
});
app.get("/", async (_req, res) => {
console.log("Login successful.");
await session.handleIncomingRedirect(`${iriBase}${_req.url}`);
// NB: This is a temporary approach, and we have work planned to properly
// collect the token. Please note that the next line is not part of the public
// API, and is therefore likely to break on non-major changes.
const rawStoredSession = await storage.get(
`solidClientAuthenticationUser:${session.info.sessionId}`
);
if(rawStoredSession === undefined) {
throw new Error(`Cannot find session with ID [${session.info.sessionId}] in storage.`);
}
const storedSession = JSON.parse(rawStoredSession);
console.log(`\nRefresh token: [${storedSession.refreshToken}]`);
console.log(`Client ID: [${storedSession.clientId}]`);
console.log(`Client Secret: [${storedSession.clientSecret}]`);
res.send(
"The tokens have been sent to the bootstraping app. You can close this window."
);
server.close();
});
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