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

@mysten/enoki

Package Overview
Dependencies
Maintainers
4
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/enoki - npm Package Compare versions

Comparing version 0.0.0-experimental-20231122055958 to 0.0.0-experimental-20231127210523

8

CHANGELOG.md
# @mysten/enoki
## 0.0.0-experimental-20231122055958
## 0.0.0-experimental-20231127210523
### Patch Changes
- 732fdbb5b: Make enoki flow session observable. Expose state parameter on useAuthCallback.
## 0.0.3
### Patch Changes
- dfa523c77: Key storage off of the API key, and add APIs for transaction block sponsorship

@@ -8,0 +14,0 @@

@@ -38,2 +38,6 @@ import type { ExecuteTransactionBlockParams, SuiClient } from '@mysten/sui.js/client';

#private;
$zkLoginSession: WritableAtom<{
initialized: boolean;
value: ZkLoginSession | null;
}>;
$zkLoginState: WritableAtom<ZkLoginState>;

@@ -40,0 +44,0 @@ constructor(config: EnokiFlowConfig);

23

dist/cjs/EnokiFlow.js

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

var import_stores = require("./stores.js");
var _storageKeys, _enokiClient, _encryption, _encryptionKey, _store, _zkLoginSessionInitialized, _zkLoginSession, _setSession, setSession_fn;
var _storageKeys, _enokiClient, _encryption, _encryptionKey, _store, _setSession, setSession_fn;
const createStorageKeys = (apiKey) => ({

@@ -68,4 +68,2 @@ STATE: `@enoki/flow/state/${apiKey}`,

__privateAdd(this, _store, void 0);
__privateAdd(this, _zkLoginSessionInitialized, void 0);
__privateAdd(this, _zkLoginSession, void 0);
__privateSet(this, _enokiClient, new import_EnokiClient.EnokiClient({

@@ -88,4 +86,3 @@ apiKey: config.apiKey,

this.$zkLoginState = (0, import_nanostores.atom)(storedState || {});
__privateSet(this, _zkLoginSessionInitialized, false);
__privateSet(this, _zkLoginSession, null);
this.$zkLoginSession = (0, import_nanostores.atom)({ initialized: false, value: null });
(0, import_nanostores.onSet)(this.$zkLoginState, ({ newValue }) => {

@@ -173,4 +170,4 @@ __privateGet(this, _store).set(__privateGet(this, _storageKeys).STATE, JSON.stringify(newValue));

async getSession() {
if (__privateGet(this, _zkLoginSessionInitialized)) {
return __privateGet(this, _zkLoginSession);
if (this.$zkLoginSession.get().initialized) {
return this.$zkLoginSession.get().value;
}

@@ -187,8 +184,8 @@ try {

} else {
__privateSet(this, _zkLoginSession, state);
this.$zkLoginSession.set({ initialized: true, value: state });
}
return __privateGet(this, _zkLoginSession);
} finally {
__privateSet(this, _zkLoginSessionInitialized, true);
} catch {
this.$zkLoginSession.set({ initialized: true, value: null });
}
return this.$zkLoginSession.get().value;
}

@@ -280,4 +277,2 @@ async logout() {

_store = new WeakMap();
_zkLoginSessionInitialized = new WeakMap();
_zkLoginSession = new WeakMap();
_setSession = new WeakSet();

@@ -294,4 +289,4 @@ setSession_fn = async function(newValue) {

}
__privateSet(this, _zkLoginSession, newValue);
this.$zkLoginSession.set({ initialized: true, value: newValue });
};
//# sourceMappingURL=EnokiFlow.js.map

@@ -10,2 +10,6 @@ import type { ReactNode } from 'react';

export declare function useZkLogin(): import("./EnokiFlow.js").ZkLoginState;
export declare function useAuthCallback(): boolean;
export declare function useZkLoginSession(): import("./EnokiFlow.js").ZkLoginSession | null;
export declare function useAuthCallback(): {
handled: boolean;
state: string | null;
};

@@ -24,3 +24,4 @@ "use strict";

useEnokiFlow: () => useEnokiFlow,
useZkLogin: () => useZkLogin
useZkLogin: () => useZkLogin,
useZkLoginSession: () => useZkLoginSession
});

@@ -48,4 +49,9 @@ module.exports = __toCommonJS(react_exports);

}
function useZkLoginSession() {
const flow = useEnokiFlow();
return (0, import_react.useStore)(flow.$zkLoginSession).value;
}
function useAuthCallback() {
const flow = useEnokiFlow();
const [state, setState] = (0, import_react2.useState)(null);
const [handled, setHandled] = (0, import_react2.useState)(false);

@@ -64,3 +70,3 @@ const [hash, setHash] = (0, import_react2.useState)(null);

try {
await flow.handleAuthCallback(hash);
setState(await flow.handleAuthCallback(hash));
window.location.hash = "";

@@ -72,4 +78,4 @@ } finally {

}, [hash, flow]);
return handled;
return { handled, state };
}
//# sourceMappingURL=react.js.map

@@ -38,2 +38,6 @@ import type { ExecuteTransactionBlockParams, SuiClient } from '@mysten/sui.js/client';

#private;
$zkLoginSession: WritableAtom<{
initialized: boolean;
value: ZkLoginSession | null;
}>;
$zkLoginState: WritableAtom<ZkLoginState>;

@@ -40,0 +44,0 @@ constructor(config: EnokiFlowConfig);

@@ -23,3 +23,3 @@ var __accessCheck = (obj, member, msg) => {

};
var _storageKeys, _enokiClient, _encryption, _encryptionKey, _store, _zkLoginSessionInitialized, _zkLoginSession, _setSession, setSession_fn;
var _storageKeys, _enokiClient, _encryption, _encryptionKey, _store, _setSession, setSession_fn;
import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";

@@ -45,4 +45,2 @@ import { fromB64, toB64 } from "@mysten/sui.js/utils";

__privateAdd(this, _store, void 0);
__privateAdd(this, _zkLoginSessionInitialized, void 0);
__privateAdd(this, _zkLoginSession, void 0);
__privateSet(this, _enokiClient, new EnokiClient({

@@ -65,4 +63,3 @@ apiKey: config.apiKey,

this.$zkLoginState = atom(storedState || {});
__privateSet(this, _zkLoginSessionInitialized, false);
__privateSet(this, _zkLoginSession, null);
this.$zkLoginSession = atom({ initialized: false, value: null });
onSet(this.$zkLoginState, ({ newValue }) => {

@@ -150,4 +147,4 @@ __privateGet(this, _store).set(__privateGet(this, _storageKeys).STATE, JSON.stringify(newValue));

async getSession() {
if (__privateGet(this, _zkLoginSessionInitialized)) {
return __privateGet(this, _zkLoginSession);
if (this.$zkLoginSession.get().initialized) {
return this.$zkLoginSession.get().value;
}

@@ -164,8 +161,8 @@ try {

} else {
__privateSet(this, _zkLoginSession, state);
this.$zkLoginSession.set({ initialized: true, value: state });
}
return __privateGet(this, _zkLoginSession);
} finally {
__privateSet(this, _zkLoginSessionInitialized, true);
} catch {
this.$zkLoginSession.set({ initialized: true, value: null });
}
return this.$zkLoginSession.get().value;
}

@@ -257,4 +254,2 @@ async logout() {

_store = new WeakMap();
_zkLoginSessionInitialized = new WeakMap();
_zkLoginSession = new WeakMap();
_setSession = new WeakSet();

@@ -271,3 +266,3 @@ setSession_fn = async function(newValue) {

}
__privateSet(this, _zkLoginSession, newValue);
this.$zkLoginSession.set({ initialized: true, value: newValue });
};

@@ -274,0 +269,0 @@ export {

@@ -10,2 +10,6 @@ import type { ReactNode } from 'react';

export declare function useZkLogin(): import("./EnokiFlow.js").ZkLoginState;
export declare function useAuthCallback(): boolean;
export declare function useZkLoginSession(): import("./EnokiFlow.js").ZkLoginSession | null;
export declare function useAuthCallback(): {
handled: boolean;
state: string | null;
};

@@ -21,4 +21,9 @@ import { jsx } from "react/jsx-runtime";

}
function useZkLoginSession() {
const flow = useEnokiFlow();
return useStore(flow.$zkLoginSession).value;
}
function useAuthCallback() {
const flow = useEnokiFlow();
const [state, setState] = useState(null);
const [handled, setHandled] = useState(false);

@@ -37,3 +42,3 @@ const [hash, setHash] = useState(null);

try {
await flow.handleAuthCallback(hash);
setState(await flow.handleAuthCallback(hash));
window.location.hash = "";

@@ -45,3 +50,3 @@ } finally {

}, [hash, flow]);
return handled;
return { handled, state };
}

@@ -52,4 +57,5 @@ export {

useEnokiFlow,
useZkLogin
useZkLogin,
useZkLoginSession
};
//# sourceMappingURL=react.js.map
{
"name": "@mysten/enoki",
"version": "0.0.0-experimental-20231122055958",
"version": "0.0.0-experimental-20231127210523",
"description": "TODO: Description",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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