Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

authkit-node-development

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authkit-node-development - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+38
-17
dist/src/apis/link.api.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEventLinkTokenApi = void 0;
exports.createEventLinkTokenApi = exports.generateId = void 0;
const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importDefault(require("axios"));
const rust_utils_1 = require("@integrationos/rust-utils");
const createEventLinkTokenApi = (headers, url, payload, secret) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const generateId = (prefix) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
var _a;
const apiBaseUrl = "https://14ef-109-48-136-70.ngrok-free.app";
try {
const response = yield axios_1.default.get(`${apiBaseUrl}/public/generate-id/${prefix}`);
const id = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.id;
return id;
}
catch (error) {
throw new Error('Failed to generate id from api');
}
});
exports.generateId = generateId;
const createEventLinkTokenApi = (headers, url, secret, payload) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
try {
const settings = yield axios_1.default.post(`${url}/v1/settings/get`, payload, { headers });
console.log("Settings is what brotherman: ", settings);
const link = yield axios_1.default.post(`${url}/v1/event-links/create`, Object.assign(Object.assign({}, payload), { environment: secret.startsWith('sk_test') ? 'test' : 'live', usageSource: 'sdk' }), { headers });
const connectionDefinitionUrl = url.includes('localhost')
? `${process.env.CONNECTIONS_API_BASE_URL}v1/public/connection-definitions`
: url.includes('development')
? 'https://development-api.integrationos.com/v1/public/connection-definitions'
: 'https://api.integrationos.com/v1/public/connection-definitions';
console.log("Link is what brotherman: ", link);
const apiBaseUrl = "https://14ef-109-48-136-70.ngrok-free.app";
const connectionDefinitionUrl = `${apiBaseUrl}/public/connection-definitions`;
const connectionDefinitions = yield axios_1.default.get(`${connectionDefinitionUrl}?limit=100&skip=0`);
console.log("Connection Definitions is what brotherman: ", connectionDefinitions);
const isLiveSecret = secret.includes('sk_live');
const activeConnectionDefinitionsData = (_b = (_a = connectionDefinitions === null || connectionDefinitions === void 0 ? void 0 : connectionDefinitions.data) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.filter((definition) => definition === null || definition === void 0 ? void 0 : definition.active);
const connectedPlatforms = (_d = (_c = settings === null || settings === void 0 ? void 0 : settings.data) === null || _c === void 0 ? void 0 : _c.connectedPlatforms) === null || _d === void 0 ? void 0 : _d.filter((platform) => {
const activeConnectionDefinitionsData = (_c = (_b = connectionDefinitions === null || connectionDefinitions === void 0 ? void 0 : connectionDefinitions.data) === null || _b === void 0 ? void 0 : _b.rows) === null || _c === void 0 ? void 0 : _c.filter((definition) => definition === null || definition === void 0 ? void 0 : definition.active);
console.log("Active Connection Definitions Data is what brotherman: ", activeConnectionDefinitionsData);
const connectedPlatforms = (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.data) === null || _d === void 0 ? void 0 : _d.connectedPlatforms) === null || _e === void 0 ? void 0 : _e.filter((platform) => {
return ((activeConnectionDefinitionsData === null || activeConnectionDefinitionsData === void 0 ? void 0 : activeConnectionDefinitionsData.find((definition) => (definition === null || definition === void 0 ? void 0 : definition._id) === (platform === null || platform === void 0 ? void 0 : platform.connectionDefinitionId))) && (platform === null || platform === void 0 ? void 0 : platform.active));
});
console.log("Connected Platforms is what brotherman: ", connectedPlatforms);
const connectedPlatformsFiltered = connectedPlatforms === null || connectedPlatforms === void 0 ? void 0 : connectedPlatforms.filter((platform) => isLiveSecret
? (platform === null || platform === void 0 ? void 0 : platform.environment) === 'live'
: (platform === null || platform === void 0 ? void 0 : platform.environment) === 'test' || !(platform === null || platform === void 0 ? void 0 : platform.environment));
console.log("Connected Platforms Filtered is what brotherman: ", connectedPlatformsFiltered);
const sessionId = yield (0, exports.generateId)('session_id');
console.log("Session Id is what brotherman: ", sessionId);
const tokenPayload = {
linkSettings: {
connectedPlatforms: connectedPlatformsFiltered !== null && connectedPlatformsFiltered !== void 0 ? connectedPlatformsFiltered : [],
eventIncToken: (_e = link === null || link === void 0 ? void 0 : link.data) === null || _e === void 0 ? void 0 : _e.token,
eventIncToken: (_f = link === null || link === void 0 ? void 0 : link.data) === null || _f === void 0 ? void 0 : _f.token,
},
group: (_f = link === null || link === void 0 ? void 0 : link.data) === null || _f === void 0 ? void 0 : _f.group,
label: (_g = link === null || link === void 0 ? void 0 : link.data) === null || _g === void 0 ? void 0 : _g.label,
identity: (_g = link === null || link === void 0 ? void 0 : link.data) === null || _g === void 0 ? void 0 : _g.identity,
identityType: (_h = link === null || link === void 0 ? void 0 : link.data) === null || _h === void 0 ? void 0 : _h.identityType,
group: (_j = link === null || link === void 0 ? void 0 : link.data) === null || _j === void 0 ? void 0 : _j.group,
label: (_k = link === null || link === void 0 ? void 0 : link.data) === null || _k === void 0 ? void 0 : _k.label,
environment: secret.startsWith('sk_test') ? 'test' : 'live',
expiresAt: new Date().getTime() + 5 * 1000 * 60,
sessionId: (0, rust_utils_1.generateId)('session_id'),
features: (_h = settings === null || settings === void 0 ? void 0 : settings.data) === null || _h === void 0 ? void 0 : _h.features,
sessionId,
features: (_l = settings === null || settings === void 0 ? void 0 : settings.data) === null || _l === void 0 ? void 0 : _l.features,
};
console.log("Token Payload is what brotherman: ", tokenPayload);
const token = yield axios_1.default.post(`${url}/v1/embed-tokens/create`, tokenPayload, { headers });
console.log("Token is what brotherman: ", token);
return token.data;

@@ -43,3 +64,3 @@ }

if (axios_1.default.isAxiosError(error)) {
return (_j = error.response) === null || _j === void 0 ? void 0 : _j.data;
return (_m = error.response) === null || _m === void 0 ? void 0 : _m.data;
}

@@ -46,0 +67,0 @@ }

@@ -1,1 +0,1 @@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,3 +30,3 @@ create(payload) {

const headers = (0, getHeaders_1.getHeaders)(secret);
const result = yield (0, apis_1.createEventLinkTokenApi)(headers, url, payload, secret);
const result = yield (0, apis_1.createEventLinkTokenApi)(headers, url, secret, payload);
return result;

@@ -33,0 +33,0 @@ });

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

{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;AAAA,oDAAiD;AACjD,kCAAkD;AAMlD,MAAa,YAAY;IAIvB,YAAY,MAAc,EAAE,UAAwB,EAAE;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKD,IAAI,WAAW;QACb,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,IAAI,IAAI;QACN,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACxB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAC7B;QAED,OAAO,wCAAwC,CAAC;IAClD,CAAC;IAEK,MAAM,CAAC,OAKZ;;YACC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACvC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YACtB,MAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;YAEnC,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAuB,EAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5E,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AAxCD,oCAwCC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;AAAA,oDAAiD;AACjD,kCAAkD;AAMlD,MAAa,YAAY;IAIvB,YAAY,MAAc,EAAE,UAAwB,EAAE;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKD,IAAI,WAAW;QACb,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,IAAI,IAAI;QACN,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACxB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAC7B;QAED,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAEK,MAAM,CAAC,OAYZ;;YACC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACvC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;YACtB,MAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;YAEnC,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAuB,EAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5E,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AA/CD,oCA+CC"}

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

return {
'X-Buildable-Secret': secret,
'X-Pica-Secret': secret,
'Content-Type': 'application/json',

@@ -9,0 +9,0 @@ };

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

{"version":3,"file":"getHeaders.js","sourceRoot":"","sources":["../../../src/logic/getHeaders.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3C,OAAO;QACL,oBAAoB,EAAE,MAAM;QAC5B,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB"}
{"version":3,"file":"getHeaders.js","sourceRoot":"","sources":["../../../src/logic/getHeaders.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3C,OAAO;QACL,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,kBAAkB;KACnC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB"}
{
"name": "authkit-node-development",
"version": "1.0.0",
"description": "Secure token generation for IntegrationOS AuthKit",
"version": "1.0.1",
"description": "Secure token generation for Pica AuthKit",
"main": "dist/index.js",

@@ -14,7 +14,7 @@ "scripts": {

"keywords": [
"integrationos",
"pica",
"integrations",
"unified api"
],
"author": "@integrationos",
"author": "@picahq",
"license": "MIT",

@@ -24,9 +24,8 @@ "dependencies": {

"axios": "^0.26.1",
"jsonwebtoken": "^9.0.1",
"jwt-decode": "^3.1.2",
"lodash.ismatch": "^4.4.0",
"lodash.memoize": "^4.1.2",
"ramda": "^0.28.0",
"tslib": "^2.4.1",
"jsonwebtoken": "^9.0.1",
"jwt-decode": "^3.1.2",
"@integrationos/rust-utils": "^1.1.3"
"tslib": "^2.4.1"
},

@@ -52,3 +51,3 @@ "devDependencies": {

"gitHead": "35ff51f0afc618c5413ef9bab778f4dcf582b8ab",
"homepage": "https://integrationos.com"
"homepage": "https://picaos.com"
}
# authkit-node
Secure token generation for [IntegrationOS AuthKit](https://docs.integrationos.com/docs/authkit) using [Node.js](https://nodejs.org/en) .
Secure token generation for [Pica AuthKit](https://docs.picaos.com/docs/authkit) using [Node.js](https://nodejs.org/en) .

@@ -10,3 +10,3 @@ ## Install

```jsx
npm i @integrationos/authkit-node
npm i @picahq/authkit-node
```

@@ -17,3 +17,3 @@

```jsx
yarn add @integrationos/authkit-node
yarn add @picahq/authkit-node
```

@@ -26,12 +26,8 @@

```jsx
import { AuthKitToken } from "@integrationos/authkit-node";
import { AuthKitToken } from "@picahq/authkit-node";
app.post("/authkit-token", async (request, response) => {
const authKitToken = new AuthKitToken("sk_live_1234");
const token = await authKitToken.create();
const token = await authKitToken.create({
group: "meaningful-id", // a meaningful identifier (i.e., organizationId)
label: "Friendly Label" // a human-friendly label (i.e., organizationName)
});
response.send(token);

@@ -43,6 +39,6 @@ });

You'll also want to populate the `Group` and `Label` fields depending on how you want to organize and query your users' connected accounts. The Group is especially important as it's used to generate the unique [Connection Key](https://docs.integrationos.com/docs/setup) for the user once they successfully connect an account.
If you pass an `identity` or `identityType` (`user`, `team`, `organization`, or `project`), you'll be able to query for all connections scoped to that identity. The identity is used to generate the unique [Connection Key](https://docs.picaos.com/docs/setup) for the user once they successfully connect an account.
## Full Documentation
Please refer to the official [IntegrationOS AuthKit](https://docs.integrationos.com/docs/authkit) docs for a more holistic understanding of IntegrationOS AuthKit.
Please refer to the official [Pica AuthKit](https://docs.picaos.com/docs/authkit) docs for a more holistic understanding of Pica AuthKit.
import axios from 'axios';
import { generateId } from '@integrationos/rust-utils';
import {

@@ -11,9 +10,28 @@ CreateEventLinkPayload,

export const generateId = async (prefix: string) => {
const apiBaseUrl = "https://14ef-109-48-136-70.ngrok-free.app";
try {
const response = await axios.get<{
id: string
}>(
`${apiBaseUrl}/public/generate-id/${prefix}`
);
const id = response?.data?.id;
return id;
} catch (error) {
throw new Error('Failed to generate id from api');
}
}
export const createEventLinkTokenApi = async (
headers: Record<string, string>,
url: string,
payload: CreateEventLinkPayload,
secret: string
secret: string,
payload?: CreateEventLinkPayload,
) => {
try {
const settings = await axios.post<LinkSettings>(

@@ -25,2 +43,4 @@ `${url}/v1/settings/get`,

console.log("Settings is what brotherman: ", settings)
const link = await axios.post<EventLink>(

@@ -36,8 +56,6 @@ `${url}/v1/event-links/create`,

const connectionDefinitionUrl = url.includes('localhost')
? `${process.env.CONNECTIONS_API_BASE_URL}v1/public/connection-definitions`
: url.includes('development')
? 'https://development-api.integrationos.com/v1/public/connection-definitions'
: 'https://api.integrationos.com/v1/public/connection-definitions';
console.log("Link is what brotherman: ", link)
const apiBaseUrl = "https://14ef-109-48-136-70.ngrok-free.app";
const connectionDefinitionUrl = `${apiBaseUrl}/public/connection-definitions`;

@@ -48,2 +66,4 @@ const connectionDefinitions = await axios.get<ConnectionDefinitions>(

console.log("Connection Definitions is what brotherman: ", connectionDefinitions)
const isLiveSecret = secret.includes('sk_live');

@@ -55,2 +75,4 @@

);
console.log("Active Connection Definitions Data is what brotherman: ", activeConnectionDefinitionsData)

@@ -67,2 +89,4 @@ const connectedPlatforms = settings?.data?.connectedPlatforms?.filter(

console.log("Connected Platforms is what brotherman: ", connectedPlatforms)
const connectedPlatformsFiltered = connectedPlatforms?.filter(

@@ -75,2 +99,8 @@ (platform) =>

console.log("Connected Platforms Filtered is what brotherman: ", connectedPlatformsFiltered)
const sessionId = await generateId('session_id');
console.log("Session Id is what brotherman: ", sessionId)
const tokenPayload = {

@@ -81,2 +111,4 @@ linkSettings: {

},
identity: link?.data?.identity,
identityType: link?.data?.identityType,
group: link?.data?.group,

@@ -86,6 +118,8 @@ label: link?.data?.label,

expiresAt: new Date().getTime() + 5 * 1000 * 60,
sessionId: generateId('session_id'),
sessionId,
features: settings?.data?.features,
};
console.log("Token Payload is what brotherman: ", tokenPayload)
const token = await axios.post<EmbedTokenRecord>(

@@ -96,2 +130,5 @@ `${url}/v1/embed-tokens/create`,

);
console.log("Token is what brotherman: ", token)
return token.data;

@@ -98,0 +135,0 @@ } catch (error) {

@@ -32,10 +32,17 @@ import { getHeaders } from '../logic/getHeaders';

return 'https://api.integrationos.com/internal';
return 'https://api.picaos.com/internal';
}
async create(payload: {
version?: string;
async create(payload?: {
ttl?: number;
/**
* Unique identifier for the token.
* @remarks It is recommended to avoid using spaces and colons in this field as it may lead to unexpected behavior in some systems.
*/
identity?: string;
identityType?: "user" | "team" | "organization" | "project";
/** @deprecated Use 'identity' instead */
group?: string;
/** @deprecated */
label?: string;
group: string;
ttl?: number;
}) {

@@ -46,5 +53,5 @@ const secret = this._clientInfo.secret;

const result = await createEventLinkTokenApi(headers, url, payload, secret);
const result = await createEventLinkTokenApi(headers, url, secret, payload);
return result;
}
}
export const getHeaders = (secret: string) => {
return {
'X-Buildable-Secret': secret,
'X-Pica-Secret': secret,
'Content-Type': 'application/json',
};
};

@@ -20,4 +20,6 @@ export interface Author {

ownership: Ownership;
label: string;
group: string;
identity?: string;
identityType?: 'user' | 'team' | 'organization' | 'project';
group?: string;
label?: string;
token: string;

@@ -35,7 +37,9 @@ createdAt: number;

version?: string;
label?: string;
group: string;
ttl?: number;
environment?: string;
usageSource?: string;
identity?: string;
identityType?: 'user' | 'team' | 'organization' | 'project';
group?: string;
label?: string;
};

@@ -124,30 +128,30 @@

export interface ConnectionRecord {
_id: string;
platformVersion: string;
connectionDefinitionId: string;
name: string;
key: string;
environment: string;
platform: string;
secretsServiceId: string;
settings: {
parseWebhookBody: boolean;
showSecret: boolean;
allowCustomEvents: boolean;
oauth: boolean;
};
throughput: {
key: string;
limit: number;
};
createdAt: number;
updatedAt: number;
updated: boolean;
version: string;
lastModifiedBy: string;
deleted: boolean;
changeLog: Record<string, any>; // You can replace 'any' with a more specific type if needed
tags: string[];
active: boolean;
deprecated: boolean;
_id: string;
platformVersion: string;
connectionDefinitionId: string;
name: string;
key: string;
environment: string;
platform: string;
secretsServiceId: string;
settings: {
parseWebhookBody: boolean;
showSecret: boolean;
allowCustomEvents: boolean;
oauth: boolean;
};
throughput: {
key: string;
limit: number;
};
createdAt: number;
updatedAt: number;
updated: boolean;
version: string;
lastModifiedBy: string;
deleted: boolean;
changeLog: Record<string, any>; // You can replace 'any' with a more specific type if needed
tags: string[];
active: boolean;
deprecated: boolean;
}

@@ -161,4 +165,6 @@

};
label: string;
group: string;
group?: string;
label?: string;
identity?: string;
identityType?: 'user' | 'team' | 'organization' | 'project';
createdAt: number;

@@ -171,9 +177,9 @@ createdDate: Date;

sessionId: string;
_id?: string;
formData?: object;
response?: {
isConnected: boolean;
message?: string;
connection?: ConnectionRecord;
}
_id?: string;
formData?: object;
response?: {
isConnected: boolean;
message?: string;
connection?: ConnectionRecord;
}
}

@@ -180,0 +186,0 @@