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

arctic

Package Overview
Dependencies
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arctic - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2

4

dist/providers/microsoft-entra-id.d.ts

@@ -5,3 +5,5 @@ import type { OAuth2Tokens } from "../oauth2.js";

private tokenEndpoint;
private client;
private clientId;
private clientSecret;
private redirectURI;
constructor(tenant: string, clientId: string, clientSecret: string | null, redirectURI: string);

@@ -8,0 +10,0 @@ createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL;

@@ -1,24 +0,69 @@

import { CodeChallengeMethod, OAuth2Client } from "../client.js";
import { joinURIAndPath } from "../request.js";
import { createS256CodeChallenge } from "../oauth2.js";
import { createOAuth2Request, encodeBasicCredentials, joinURIAndPath, sendTokenRequest } from "../request.js";
export class MicrosoftEntraId {
authorizationEndpoint;
tokenEndpoint;
client;
clientId;
clientSecret;
redirectURI;
constructor(tenant, clientId, clientSecret, redirectURI) {
this.authorizationEndpoint = joinURIAndPath("https://login.microsoftonline.com", tenant, "/oauth2/v2.0/authorize");
this.tokenEndpoint = joinURIAndPath("https://login.microsoftonline.com", tenant, "/oauth2/v2.0/token");
this.client = new OAuth2Client(clientId, clientSecret, redirectURI);
this.clientId = clientId;
this.clientSecret = clientSecret;
this.redirectURI = redirectURI;
}
createAuthorizationURL(state, codeVerifier, scopes) {
const url = this.client.createAuthorizationURLWithPKCE(this.authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
const url = new URL(this.authorizationEndpoint);
url.searchParams.set("response_type", "code");
url.searchParams.set("client_id", this.clientId);
url.searchParams.set("redirect_uri", this.redirectURI);
url.searchParams.set("state", state);
const codeChallenge = createS256CodeChallenge(codeVerifier);
url.searchParams.set("code_challenge_method", "S256");
url.searchParams.set("code_challenge", codeChallenge);
if (scopes.length > 0) {
url.searchParams.set("scope", scopes.join(" "));
}
return url;
}
async validateAuthorizationCode(code, codeVerifier) {
const tokens = await this.client.validateAuthorizationCode(this.tokenEndpoint, code, codeVerifier);
const body = new URLSearchParams();
body.set("grant_type", "authorization_code");
body.set("code", code);
body.set("redirect_uri", this.redirectURI);
body.set("code_verifier", codeVerifier);
if (this.clientSecret === null) {
body.set("client_id", this.clientId);
}
const request = createOAuth2Request(this.tokenEndpoint, body);
// Origin header required for public clients. Value can be anything.
request.headers.set("Origin", "arctic");
if (this.clientSecret !== null) {
const encodedCredentials = encodeBasicCredentials(this.clientId, this.clientId);
request.headers.set("Authorization", `Basic ${encodedCredentials}`);
}
const tokens = await sendTokenRequest(request);
return tokens;
}
async refreshAccessToken(refreshToken, scopes) {
const tokens = await this.client.refreshAccessToken(this.tokenEndpoint, refreshToken, scopes);
const body = new URLSearchParams();
body.set("grant_type", "refresh_token");
body.set("refresh_token", refreshToken);
if (this.clientSecret === null) {
body.set("client_id", this.clientId);
}
if (scopes.length > 0) {
body.set("scope", scopes.join(" "));
}
const request = createOAuth2Request(this.tokenEndpoint, body);
// Origin header required for public clients. Value can be anything.
request.headers.set("Origin", "arctic");
if (this.clientSecret !== null) {
const encodedCredentials = encodeBasicCredentials(this.clientId, this.clientSecret);
request.headers.set("Authorization", `Basic ${encodedCredentials}`);
}
const tokens = await sendTokenRequest(request);
return tokens;
}
}
{
"name": "arctic",
"type": "module",
"version": "3.2.1",
"version": "3.2.2",
"description": "OAuth 2.0 clients for popular providers",

@@ -6,0 +6,0 @@ "main": "dist/index.js",

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