Socket
Socket
Sign inDemoInstall

@octokit/oauth-authorization-url

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/oauth-authorization-url - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1

65

dist-node/index.js

@@ -5,56 +5,7 @@ 'use strict';

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function oauthAuthorizationUrl(options) {
const scopesNormalized = typeof options.scopes === "string" ? options.scopes.split(/[,\s]+/).filter(Boolean) : Array.isArray(options.scopes) ? options.scopes : [];
const clientType = options.clientType || "oauth-app";
const baseUrl = options.baseUrl || "https://github.com";
const common = {
const result = {
clientType,
allowSignup: options.allowSignup === false ? false : true,

@@ -67,8 +18,8 @@ clientId: options.clientId,

};
const result = clientType === "oauth-app" ? _objectSpread2(_objectSpread2({}, common), {}, {
clientType: "oauth-app",
scopes: scopesNormalized
}) : _objectSpread2(_objectSpread2({}, common), {}, {
clientType: "github-app"
});
if (clientType === "oauth-app") {
const scopes = "scopes" in options ? options.scopes : [];
result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes;
}
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result);

@@ -75,0 +26,0 @@ return result;

25

dist-src/index.js
export function oauthAuthorizationUrl(options) {
const scopesNormalized = typeof options.scopes === "string"
? options.scopes.split(/[,\s]+/).filter(Boolean)
: Array.isArray(options.scopes)
? options.scopes
: [];
const clientType = options.clientType || "oauth-app";
const baseUrl = options.baseUrl || "https://github.com";
const common = {
const result = {
clientType,
allowSignup: options.allowSignup === false ? false : true,

@@ -17,12 +13,9 @@ clientId: options.clientId,

};
const result = clientType === "oauth-app"
? {
...common,
clientType: "oauth-app",
scopes: scopesNormalized,
}
: {
...common,
clientType: "github-app",
};
if (clientType === "oauth-app") {
const scopes = "scopes" in options ? options.scopes : [];
result.scopes =
typeof scopes === "string"
? scopes.split(/[,\s]+/).filter(Boolean)
: scopes;
}
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result);

@@ -29,0 +22,0 @@ return result;

@@ -1,3 +0,4 @@

import { ClientType, Options, Result } from "./types";
export { ClientType, Options, Result } from "./types";
export declare function oauthAuthorizationUrl<TClientType extends ClientType = "oauth-app">(options: Options<TClientType>): Result<TClientType>;
import { OAuthAppOptions, GitHubAppOptions, OAuthAppResult, GitHubAppResult } from "./types";
export { ClientType, OAuthAppOptions, GitHubAppOptions, OAuthAppResult, GitHubAppResult, } from "./types";
export declare function oauthAuthorizationUrl(options: OAuthAppOptions): OAuthAppResult;
export declare function oauthAuthorizationUrl(options: GitHubAppOptions): GitHubAppResult;
export declare type ClientType = "oauth-app" | "github-app";
export declare type OAuthAppOptions<TClientType extends "oauth-app"> = {
export declare type OAuthAppOptions = {
clientId: string;
clientType?: TClientType;
clientType?: "oauth-app";
allowSignup?: boolean;

@@ -12,7 +12,5 @@ login?: string;

};
export declare type GitHubAppOptions<TClientType extends "github-app"> = {
export declare type GitHubAppOptions = {
clientId: string;
clientType: TClientType;
/** `scopes` are not permitted for GitHub Apps */
scopes?: never;
clientType: "github-app";
allowSignup?: boolean;

@@ -24,7 +22,6 @@ login?: string;

};
export declare type Options<TClientType extends ClientType> = TClientType extends "oauth-app" ? OAuthAppOptions<TClientType> : TClientType extends "github-app" ? GitHubAppOptions<TClientType> : never;
declare type OAuthAppResult<TClientType extends "oauth-app"> = {
export declare type OAuthAppResult = {
allowSignup: boolean;
clientId: string;
clientType: TClientType;
clientType: "oauth-app";
login: string | null;

@@ -36,6 +33,6 @@ redirectUrl: string | null;

};
declare type GitHubAppResult<TClientType extends "github-app"> = {
export declare type GitHubAppResult = {
allowSignup: boolean;
clientId: string;
clientType: TClientType;
clientType: "github-app";
login: string | null;

@@ -46,3 +43,1 @@ redirectUrl: string | null;

};
export declare type Result<TClientType extends ClientType> = TClientType extends "oauth-app" ? OAuthAppResult<TClientType> : TClientType extends "github-app" ? GitHubAppResult<TClientType> : never;
export {};
function oauthAuthorizationUrl(options) {
const scopesNormalized = typeof options.scopes === "string"
? options.scopes.split(/[,\s]+/).filter(Boolean)
: Array.isArray(options.scopes)
? options.scopes
: [];
const clientType = options.clientType || "oauth-app";
const baseUrl = options.baseUrl || "https://github.com";
const common = {
const result = {
clientType,
allowSignup: options.allowSignup === false ? false : true,

@@ -17,12 +13,9 @@ clientId: options.clientId,

};
const result = clientType === "oauth-app"
? {
...common,
clientType: "oauth-app",
scopes: scopesNormalized,
}
: {
...common,
clientType: "github-app",
};
if (clientType === "oauth-app") {
const scopes = "scopes" in options ? options.scopes : [];
result.scopes =
typeof scopes === "string"
? scopes.split(/[,\s]+/).filter(Boolean)
: scopes;
}
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result);

@@ -29,0 +22,0 @@ return result;

{
"name": "@octokit/oauth-authorization-url",
"description": "Universal library to retrieve GitHub’s identity URL for the OAuth web flow",
"version": "4.3.0",
"version": "4.3.1",
"license": "MIT",

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

@@ -270,11 +270,13 @@ # oauth-authorization-url.js

```ts
import { ClientType, Options, Result } from "@octokit/oauth-authorization-url";
import {
ClientType,
OAuthAppOptions,
OAuthAppResult,
GitHubAppOptions,
GitHubAppResult,
} from "@octokit/oauth-authorization-url";
```
- `ClientType` is a union of `"oauth-app"` and `"github-app"`
- `Options<"oauth-app">` returns types for OAuth Apps Options. `Options<"github-app">` returns types for GitHub Apps Options.
- `Result<"oauth-app">` returns types for OAuth Apps Result object. `Result<"github-app">` returns types for GitHub Apps Result object.
## License
[MIT](LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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