@workos-inc/node
Advanced tools
Comparing version 0.2.4 to 0.3.0
{ | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"name": "@workos-inc/node", | ||
@@ -41,12 +41,12 @@ "author": "WorkOS", | ||
"@types/jest": "25.2.1", | ||
"@types/node": "12.12.35", | ||
"@types/node": "12.12.37", | ||
"@types/pluralize": "0.0.29", | ||
"axios-mock-adapter": "1.18.1", | ||
"jest": "25.3.0", | ||
"prettier": "2.0.4", | ||
"jest": "25.5.2", | ||
"prettier": "2.0.5", | ||
"supertest": "4.0.2", | ||
"ts-jest": "25.3.1", | ||
"tslint": "6.1.1", | ||
"ts-jest": "25.4.0", | ||
"tslint": "6.1.2", | ||
"typescript": "3.8.3" | ||
} | ||
} |
import { AuthorizationURLOptions } from './interfaces/authorization-url-options.interface'; | ||
import { Connection } from './interfaces/connection.interface'; | ||
import { CreateConnectionOptions } from './interfaces/create-connection-options.interface'; | ||
import { GetProfileOptions } from './interfaces/get-profile-options.interface'; | ||
@@ -9,2 +11,3 @@ import { Profile } from './interfaces/profile.interface'; | ||
constructor(workos: WorkOS); | ||
createConnection({ source, }: CreateConnectionOptions): Promise<Connection>; | ||
getAuthorizationURL({ domain, projectID, provider, redirectURI, state, }: AuthorizationURLOptions): string; | ||
@@ -11,0 +14,0 @@ getProfile({ code, projectID }: GetProfileOptions): Promise<Profile>; |
@@ -20,2 +20,8 @@ "use strict"; | ||
} | ||
createConnection({ source, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { data } = yield this.workos.post('/connections', { source }); | ||
return data; | ||
}); | ||
} | ||
getAuthorizationURL({ domain, projectID, provider, redirectURI, state, }) { | ||
@@ -48,2 +54,3 @@ if (!domain && !provider) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.workos.emitWarning('[Deprecated] sso.promoteDraftConnection({ token }) is deprecated. Use sso.createConnection({ source }) instead.'); | ||
const endpoint = `/draft_connections/${token}/activate`; | ||
@@ -50,0 +57,0 @@ yield this.workos.post(endpoint, null); |
import { AxiosResponse } from 'axios'; | ||
import { AuditTrail } from './audit-trail/audit-trail'; | ||
import { DirectorySync } from './directory-sync/directory-sync'; | ||
import { SSO } from './sso/sso'; | ||
@@ -11,6 +12,9 @@ import { WorkOSOptions, PostOptions } from './common/interfaces'; | ||
readonly auditTrail: AuditTrail; | ||
readonly directorySync: DirectorySync; | ||
readonly sso: SSO; | ||
constructor(key?: string | undefined, options?: WorkOSOptions); | ||
post(path: string, entity: any, options?: PostOptions): Promise<AxiosResponse>; | ||
get(path: string, query?: any): Promise<AxiosResponse>; | ||
emitWarning(warning: string): void; | ||
} | ||
export default WorkOS; |
@@ -17,2 +17,3 @@ "use strict"; | ||
const audit_trail_1 = require("./audit-trail/audit-trail"); | ||
const directory_sync_1 = require("./directory-sync/directory-sync"); | ||
const exceptions_1 = require("./common/exceptions"); | ||
@@ -27,2 +28,3 @@ const sso_1 = require("./sso/sso"); | ||
this.auditTrail = new audit_trail_1.AuditTrail(this); | ||
this.directorySync = new directory_sync_1.DirectorySync(this); | ||
this.sso = new sso_1.SSO(this); | ||
@@ -90,2 +92,41 @@ if (!key) { | ||
} | ||
get(path, query) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
return yield this.client.get(path, { | ||
params: query, | ||
}); | ||
} | ||
catch (error) { | ||
const { response } = error; | ||
if (response) { | ||
const { status, data, headers } = response; | ||
const requestID = headers['X-Request-ID']; | ||
switch (status) { | ||
case 401: { | ||
throw new exceptions_1.UnauthorizedException(requestID); | ||
} | ||
case 422: { | ||
const { errors } = data; | ||
throw new exceptions_1.UnprocessableEntityException(errors, requestID); | ||
} | ||
case 404: { | ||
throw new exceptions_1.NotFoundException(path, requestID); | ||
} | ||
default: { | ||
throw new exceptions_1.GenericServerException(status, data.message, requestID); | ||
} | ||
} | ||
} | ||
throw error; | ||
} | ||
}); | ||
} | ||
emitWarning(warning) { | ||
if (typeof process.emitWarning !== 'function') { | ||
// tslint:disable:no-console | ||
return console.warn(`Stripe: ${warning}`); | ||
} | ||
return process.emitWarning(warning, 'WorkOS'); | ||
} | ||
} | ||
@@ -92,0 +133,0 @@ exports.WorkOS = WorkOS; |
{ | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"name": "@workos-inc/node", | ||
@@ -41,12 +41,12 @@ "author": "WorkOS", | ||
"@types/jest": "25.2.1", | ||
"@types/node": "12.12.35", | ||
"@types/node": "12.12.37", | ||
"@types/pluralize": "0.0.29", | ||
"axios-mock-adapter": "1.18.1", | ||
"jest": "25.3.0", | ||
"prettier": "2.0.4", | ||
"jest": "25.5.2", | ||
"prettier": "2.0.5", | ||
"supertest": "4.0.2", | ||
"ts-jest": "25.3.1", | ||
"tslint": "6.1.1", | ||
"ts-jest": "25.4.0", | ||
"tslint": "6.1.2", | ||
"typescript": "3.8.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
34086
73
704
0