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

@vonage/auth-client-sdk

Package Overview
Dependencies
Maintainers
42
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/auth-client-sdk - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

2

dst/consts.d.ts

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

export declare const SDK_VERSION = "1.2.7";
export declare const SDK_VERSION = "1.2.8";
export type Environment = 'LOCAL' | 'DEV' | 'QA' | 'PROD';
export declare const Remotes: Record<Environment, string>;
export declare const EnvironmentKeys: string[];

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

export const SDK_VERSION = '1.2.7';
export const SDK_VERSION = '1.2.8'; // this MUST NOT be changed in any PR
export const Remotes = {

@@ -3,0 +3,0 @@ LOCAL: 'sdk.auth.vocal-dev.com',

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

var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _VBCAuthVault_instances, _a, _VBCAuthVault_instance, _VBCAuthVault_env, _VBCAuthVault_interopFrame, _VBCAuthVault_interopFrameReady, _VBCAuthVault_callbackMessageTypes, _VBCAuthVault_callbacksRegistry, _VBCAuthVault_vaultMessageHandler;
import { VaultMessage, VaultMessageType } from './vault-types.js';

@@ -5,27 +17,27 @@ import { getRandomId } from '../utils.js';

export class VBCAuthVault {
static #instance;
#env;
#interopFrame;
#interopFrameReady;
#callbackMessageTypes = [VaultMessageType.RESPONSE_STORE, VaultMessageType.RESPONSE_RETRIEVE, VaultMessageType.RESPONSE_REMOVE];
#callbacksRegistry;
constructor(env) {
_VBCAuthVault_instances.add(this);
_VBCAuthVault_env.set(this, void 0);
_VBCAuthVault_interopFrame.set(this, void 0);
_VBCAuthVault_interopFrameReady.set(this, void 0);
_VBCAuthVault_callbackMessageTypes.set(this, [VaultMessageType.RESPONSE_STORE, VaultMessageType.RESPONSE_RETRIEVE, VaultMessageType.RESPONSE_REMOVE]);
_VBCAuthVault_callbacksRegistry.set(this, void 0);
if (!env || !EnvironmentKeys.includes(String(env))) {
throw new Error(`invalid env '${env}', expected one of [${EnvironmentKeys}]`);
}
this.#env = env;
this.#interopFrame = setupVault(env);
this.#interopFrameReady = setupIFrameReadyPromise(this.#interopFrame);
this.#callbacksRegistry = {};
globalThis.addEventListener('message', this.#vaultMessageHandler.bind(this));
__classPrivateFieldSet(this, _VBCAuthVault_env, env, "f");
__classPrivateFieldSet(this, _VBCAuthVault_interopFrame, setupVault(env), "f");
__classPrivateFieldSet(this, _VBCAuthVault_interopFrameReady, setupIFrameReadyPromise(__classPrivateFieldGet(this, _VBCAuthVault_interopFrame, "f")), "f");
__classPrivateFieldSet(this, _VBCAuthVault_callbacksRegistry, {}, "f");
globalThis.addEventListener('message', __classPrivateFieldGet(this, _VBCAuthVault_instances, "m", _VBCAuthVault_vaultMessageHandler).bind(this));
console.info(`initialized VBCAuthVault: version ${SDK_VERSION}, environment '${env}'`);
}
static getInstance(env) {
if (!VBCAuthVault.#instance) {
VBCAuthVault.#instance = new VBCAuthVault(env);
if (!__classPrivateFieldGet(VBCAuthVault, _a, "f", _VBCAuthVault_instance)) {
__classPrivateFieldSet(VBCAuthVault, _a, new VBCAuthVault(env), "f", _VBCAuthVault_instance);
}
if (VBCAuthVault.#instance.#env !== env) {
throw new Error(`VBCAuthVault already initialized for env '${VBCAuthVault.#instance.#env}', refusing to init another one for env '${env}'`);
if (__classPrivateFieldGet(__classPrivateFieldGet(VBCAuthVault, _a, "f", _VBCAuthVault_instance), _VBCAuthVault_env, "f") !== env) {
throw new Error(`VBCAuthVault already initialized for env '${__classPrivateFieldGet(__classPrivateFieldGet(VBCAuthVault, _a, "f", _VBCAuthVault_instance), _VBCAuthVault_env, "f")}', refusing to init another one for env '${env}'`);
}
return VBCAuthVault.#instance;
return __classPrivateFieldGet(VBCAuthVault, _a, "f", _VBCAuthVault_instance);
}

@@ -39,3 +51,3 @@ async store(key, value) {

}
await this.#interopFrameReady;
await __classPrivateFieldGet(this, _VBCAuthVault_interopFrameReady, "f");
const mid = getRandomId();

@@ -45,3 +57,3 @@ console.info(`requested to store item (id: ${mid})...`);

// setup awaiting callback
this.#callbacksRegistry[mid] = { resolver: resolve };
__classPrivateFieldGet(this, _VBCAuthVault_callbacksRegistry, "f")[mid] = { resolver: resolve };
// send actual request

@@ -53,3 +65,3 @@ const message = {

};
this.#interopFrame.contentWindow?.postMessage(message, '*');
__classPrivateFieldGet(this, _VBCAuthVault_interopFrame, "f").contentWindow?.postMessage(message, '*');
});

@@ -61,3 +73,3 @@ }

}
await this.#interopFrameReady;
await __classPrivateFieldGet(this, _VBCAuthVault_interopFrameReady, "f");
const mid = getRandomId();

@@ -67,3 +79,3 @@ console.info(`requested to retrieve item (id: ${mid})...`);

// setup awaiting callback
this.#callbacksRegistry[mid] = { resolver: resolve };
__classPrivateFieldGet(this, _VBCAuthVault_callbacksRegistry, "f")[mid] = { resolver: resolve };
// send actual request

@@ -75,3 +87,3 @@ const message = {

};
this.#interopFrame.contentWindow?.postMessage(message, '*');
__classPrivateFieldGet(this, _VBCAuthVault_interopFrame, "f").contentWindow?.postMessage(message, '*');
});

@@ -83,3 +95,3 @@ }

}
await this.#interopFrameReady;
await __classPrivateFieldGet(this, _VBCAuthVault_interopFrameReady, "f");
const mid = getRandomId();

@@ -89,3 +101,3 @@ console.info(`requested to remove item (id: ${mid})...`);

// setup awaiting callback
this.#callbacksRegistry[mid] = { resolver: resolve };
__classPrivateFieldGet(this, _VBCAuthVault_callbacksRegistry, "f")[mid] = { resolver: resolve };
// send actual request

@@ -97,35 +109,36 @@ const message = {

};
this.#interopFrame.contentWindow?.postMessage(message, '*');
__classPrivateFieldGet(this, _VBCAuthVault_interopFrame, "f").contentWindow?.postMessage(message, '*');
});
}
#vaultMessageHandler(me) {
const { id, type, body } = me.data;
// validate message type
if (!this.#callbackMessageTypes.includes(type)) {
return;
}
// validate message ID
if (!id) {
console.error('missing message ID, something went wrong...');
return;
}
// validate pending result
const resultAwaiter = this.#callbacksRegistry[id];
if (!resultAwaiter) {
console.error(`received a callback for message '${id}', but not found pending result, see the logs above for an errors (timeout?)`);
return;
}
// deliver callback
try {
resultAwaiter.resolver(body);
console.info(`delivered value for '${id}'`);
}
catch (error) {
console.error(`failed to deliver value for '${id}'`, error);
}
finally {
delete this.#callbacksRegistry[id];
}
}
_a = VBCAuthVault, _VBCAuthVault_env = new WeakMap(), _VBCAuthVault_interopFrame = new WeakMap(), _VBCAuthVault_interopFrameReady = new WeakMap(), _VBCAuthVault_callbackMessageTypes = new WeakMap(), _VBCAuthVault_callbacksRegistry = new WeakMap(), _VBCAuthVault_instances = new WeakSet(), _VBCAuthVault_vaultMessageHandler = function _VBCAuthVault_vaultMessageHandler(me) {
const { id, type, body } = me.data;
// validate message type
if (!__classPrivateFieldGet(this, _VBCAuthVault_callbackMessageTypes, "f").includes(type)) {
return;
}
}
// validate message ID
if (!id) {
console.error('missing message ID, something went wrong...');
return;
}
// validate pending result
const resultAwaiter = __classPrivateFieldGet(this, _VBCAuthVault_callbacksRegistry, "f")[id];
if (!resultAwaiter) {
console.error(`received a callback for message '${id}', but not found pending result, see the logs above for an errors (timeout?)`);
return;
}
// deliver callback
try {
resultAwaiter.resolver(body);
console.info(`delivered value for '${id}'`);
}
catch (error) {
console.error(`failed to deliver value for '${id}'`, error);
}
finally {
delete __classPrivateFieldGet(this, _VBCAuthVault_callbacksRegistry, "f")[id];
}
};
_VBCAuthVault_instance = { value: void 0 };
function setupVault(env) {

@@ -132,0 +145,0 @@ const url = env === 'LOCAL'

@@ -11,5 +11,2 @@ export var VaultMessageType;

export class VaultMessage {
key;
value;
error;
constructor(key, value = null, error = null) {

@@ -16,0 +13,0 @@ this.key = key;

{
"name": "@vonage/auth-client-sdk",
"version": "1.2.7",
"version": "1.2.8",
"type": "module",

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

@@ -10,9 +10,6 @@ # Auth client SDK

```
or, most likely, as a dynamic import:
```
const VBCAuthVault = (await import('https://sdk.auth.vonage.com/1.2.3/main.js')).VBCAuthVault;
```
or, less preferred, as an import from local `node_modules`:
- first do `npm i @vonage/auth-client-sdk`
- then import similar to above, just using your relative paths structure
> Note: an exact version (`1.2.3` in the examples above) will always match the (last portion of the) deployed version tag. See this repo's relevant tags or consult with the Cerberus team for the suitable version.
## CI/CD

@@ -49,3 +46,3 @@

VBCAuthVault {
static getInstance(): VBCAuthVault;
static getInstance(env: string): VBCAuthVault;

@@ -58,2 +55,4 @@ store(key: string, value: string): Promise<VaultMessage>;

> `env` parameter of `getInstance` MUST be one of those: `DEV`, `QA` or `PROD`.
#### `VaultMessage`

@@ -60,0 +59,0 @@

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