Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trinsic/trinsic

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trinsic/trinsic - npm Package Compare versions

Comparing version 1.11.3-pre.10 to 1.11.3-pre.11

23

lib/src/ConnectClient.d.ts

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

import { OidcClient, OidcClientSettings } from "oidc-client-ts";
export interface MobileDetect {

@@ -10,2 +11,5 @@ isMobile: boolean;

baseUrl: string;
oidcConfig: OidcClientSettings;
oidcClient?: OidcClient;
popupWindow?: Window | null;
constructor(connectUrl?: string);

@@ -17,3 +21,5 @@ detectMobile: () => MobileDetect;

identityVerification(clientToken: string): Promise<any>;
static requestVerifableCredential(request: IVerifiableCredentialRequest): Promise<any>;
processCallback: (response: any) => void;
requestVerifiableCredential(request: IVerifiableCredentialRequest): Promise<any>;
openPopup: (url: string) => Window | null;
}

@@ -23,16 +29,3 @@ export interface IVerifiableCredentialRequest {

schema: string;
popupWindowFeatures?: PopupWindowFeatures;
verificationTemplateId?: string;
}
export declare interface PopupWindowFeatures {
left?: number;
top?: number;
width?: number;
height?: number;
menubar?: boolean | string;
toolbar?: boolean | string;
location?: boolean | string;
status?: boolean | string;
resizable?: boolean | string;
scrollbars?: boolean | string;
[k: string]: boolean | string | number | undefined;
}

@@ -231,2 +231,15 @@ "use strict";

constructor(connectUrl = "https://connect.trinsic.cloud") {
this.oidcConfig = {
authority: "https://connect.trinsic.cloud/",
client_id: "http://localhost:8080/",
redirect_uri: "http://localhost:8080/",
response_type: "code",
scope: "openid",
extraQueryParams: {
"trinsic:ecosystem": "",
"trinsic:schema": "",
"trinsic:mode": "popup",
},
stateStore: new oidc_client_ts_1.WebStorageStateStore({ store: window.localStorage }),
};
this.detectMobile = () => {

@@ -279,2 +292,17 @@ const mobileDetect = getMobileDetect(navigator.userAgent);

};
this.processCallback = (response) => { };
this.openPopup = (url) => {
// Calculate the position
const w = 600;
const h = 800;
const left = window.screen.width / 2 - w / 2;
const top = window.screen.height / 2 - h / 2;
// Open the window
const popup = window.open(url, "oidc-popup", `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${top}, left=${left}`);
// Check if the popup was blocked
if (popup === null || typeof popup === "undefined") {
alert("Popup blocked, please enable popups and try again");
}
return popup;
};
this.baseUrl = connectUrl;

@@ -286,2 +314,8 @@ micromodal_1.default.init();

document.head.appendChild(style);
window.addEventListener("message", async (e) => {
var _a;
var response = await this.oidcClient.processSigninResponse(e.data.url);
(_a = this.popupWindow) === null || _a === void 0 ? void 0 : _a.close();
this.processCallback(response);
});
}

@@ -312,34 +346,16 @@ async identityVerification(clientToken) {

}
static async requestVerifableCredential(request) {
async requestVerifiableCredential(request) {
if (!request || !request.ecosystem || !request.schema) {
throw new Error("ecosystem and schema are required");
}
var config = {
authority: "https://connect.trinsic.cloud/",
client_id: "http://localhost:8080/",
redirect_uri: "http://localhost:8080/",
popupWindowFeatures: Object.assign(Object.assign({}, request.popupWindowFeatures), {
menubar: "yes",
location: "yes",
toolbar: "yes",
width: 1200,
height: 800,
left: 100,
top: 100,
resizable: "yes",
}),
response_type: "code",
scope: "openid",
extraQueryParams: {
"trinsic:ecosystem": request.ecosystem,
"trinsic:schema": request.schema,
"trinsic:mode": "popup",
},
userStore: new oidc_client_ts_1.WebStorageStateStore({ store: window.localStorage }),
};
var manager = new oidc_client_ts_1.UserManager(config);
window.addEventListener("message", (e) => {
manager.signinPopupCallback();
const settings = Object.assign({}, this.oidcConfig);
settings.extraQueryParams["trinsic:ecosystem"] = request.ecosystem;
settings.extraQueryParams["trinsic:schema"] = request.schema;
this.oidcClient = new oidc_client_ts_1.OidcClient(settings);
var authRequest = await this.oidcClient.createSigninRequest({});
this.popupWindow = this.openPopup(authRequest.url);
var result = new Promise((resolve, reject) => {
this.processCallback = resolve;
});
return await manager.signinPopup();
return result;
}

@@ -346,0 +362,0 @@ }

{
"name": "@trinsic/trinsic",
"version": "1.11.3-pre.10",
"version": "1.11.3-pre.11",
"description": "Node and Browser wrapper for the Trinsic services",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is too big to display

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