@haneullabs/enoki 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1109 -0
- package/README.md +1 -0
- package/dist/cjs/EnokiClient/index.d.ts +36 -0
- package/dist/cjs/EnokiClient/index.js +196 -0
- package/dist/cjs/EnokiClient/index.js.map +7 -0
- package/dist/cjs/EnokiClient/type.d.ts +119 -0
- package/dist/cjs/EnokiClient/type.js +17 -0
- package/dist/cjs/EnokiClient/type.js.map +7 -0
- package/dist/cjs/EnokiFlow.d.ts +74 -0
- package/dist/cjs/EnokiFlow.js +279 -0
- package/dist/cjs/EnokiFlow.js.map +7 -0
- package/dist/cjs/EnokiKeypair.d.ts +20 -0
- package/dist/cjs/EnokiKeypair.js +87 -0
- package/dist/cjs/EnokiKeypair.js.map +7 -0
- package/dist/cjs/encryption.d.ts +15 -0
- package/dist/cjs/encryption.js +96 -0
- package/dist/cjs/encryption.js.map +7 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/react.d.ts +20 -0
- package/dist/cjs/react.js +76 -0
- package/dist/cjs/react.js.map +7 -0
- package/dist/cjs/stores.d.ts +21 -0
- package/dist/cjs/stores.js +67 -0
- package/dist/cjs/stores.js.map +7 -0
- package/dist/cjs/utils.d.ts +2 -0
- package/dist/cjs/utils.js +27 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/cjs/wallet/features.d.ts +50 -0
- package/dist/cjs/wallet/features.js +27 -0
- package/dist/cjs/wallet/features.js.map +7 -0
- package/dist/cjs/wallet/initializer.d.ts +11 -0
- package/dist/cjs/wallet/initializer.js +41 -0
- package/dist/cjs/wallet/initializer.js.map +7 -0
- package/dist/cjs/wallet/providers.d.ts +7 -0
- package/dist/cjs/wallet/providers.js +51 -0
- package/dist/cjs/wallet/providers.js.map +7 -0
- package/dist/cjs/wallet/register.d.ts +7 -0
- package/dist/cjs/wallet/register.js +68 -0
- package/dist/cjs/wallet/register.js.map +7 -0
- package/dist/cjs/wallet/state.d.ts +18 -0
- package/dist/cjs/wallet/state.js +142 -0
- package/dist/cjs/wallet/state.js.map +7 -0
- package/dist/cjs/wallet/types.d.ts +82 -0
- package/dist/cjs/wallet/types.js +17 -0
- package/dist/cjs/wallet/types.js.map +7 -0
- package/dist/cjs/wallet/utils.d.ts +11 -0
- package/dist/cjs/wallet/utils.js +83 -0
- package/dist/cjs/wallet/utils.js.map +7 -0
- package/dist/cjs/wallet/wallet.d.ts +16 -0
- package/dist/cjs/wallet/wallet.js +466 -0
- package/dist/cjs/wallet/wallet.js.map +7 -0
- package/dist/esm/EnokiClient/index.d.ts +36 -0
- package/dist/esm/EnokiClient/index.js +176 -0
- package/dist/esm/EnokiClient/index.js.map +7 -0
- package/dist/esm/EnokiClient/type.d.ts +119 -0
- package/dist/esm/EnokiClient/type.js +1 -0
- package/dist/esm/EnokiClient/type.js.map +7 -0
- package/dist/esm/EnokiFlow.d.ts +74 -0
- package/dist/esm/EnokiFlow.js +259 -0
- package/dist/esm/EnokiFlow.js.map +7 -0
- package/dist/esm/EnokiKeypair.d.ts +20 -0
- package/dist/esm/EnokiKeypair.js +67 -0
- package/dist/esm/EnokiKeypair.js.map +7 -0
- package/dist/esm/encryption.d.ts +15 -0
- package/dist/esm/encryption.js +76 -0
- package/dist/esm/encryption.js.map +7 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +41 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/react.d.ts +20 -0
- package/dist/esm/react.js +56 -0
- package/dist/esm/react.js.map +7 -0
- package/dist/esm/stores.d.ts +21 -0
- package/dist/esm/stores.js +47 -0
- package/dist/esm/stores.js.map +7 -0
- package/dist/esm/utils.d.ts +2 -0
- package/dist/esm/utils.js +7 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/esm/wallet/features.d.ts +50 -0
- package/dist/esm/wallet/features.js +7 -0
- package/dist/esm/wallet/features.js.map +7 -0
- package/dist/esm/wallet/initializer.d.ts +11 -0
- package/dist/esm/wallet/initializer.js +21 -0
- package/dist/esm/wallet/initializer.js.map +7 -0
- package/dist/esm/wallet/providers.d.ts +7 -0
- package/dist/esm/wallet/providers.js +31 -0
- package/dist/esm/wallet/providers.js.map +7 -0
- package/dist/esm/wallet/register.d.ts +7 -0
- package/dist/esm/wallet/register.js +48 -0
- package/dist/esm/wallet/register.js.map +7 -0
- package/dist/esm/wallet/state.d.ts +18 -0
- package/dist/esm/wallet/state.js +122 -0
- package/dist/esm/wallet/state.js.map +7 -0
- package/dist/esm/wallet/types.d.ts +82 -0
- package/dist/esm/wallet/types.js +1 -0
- package/dist/esm/wallet/types.js.map +7 -0
- package/dist/esm/wallet/utils.d.ts +11 -0
- package/dist/esm/wallet/utils.js +63 -0
- package/dist/esm/wallet/utils.js.map +7 -0
- package/dist/esm/wallet/wallet.d.ts +16 -0
- package/dist/esm/wallet/wallet.js +444 -0
- package/dist/esm/wallet/wallet.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +80 -0
- package/react/package.json +5 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WritableAtom } from 'nanostores';
|
|
2
|
+
import type { EnokiClientConfig } from '../EnokiClient/index.js';
|
|
3
|
+
import type { ClientWithCoreApi, Experimental_HaneulClientTypes } from '@haneullabs/haneul/experimental';
|
|
4
|
+
import type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';
|
|
5
|
+
export type EnokiWalletStateConfig = EnokiClientConfig & {
|
|
6
|
+
clients: ClientWithCoreApi[];
|
|
7
|
+
clientId: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class EnokiWalletState {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(config: EnokiWalletStateConfig);
|
|
12
|
+
get zkLoginState(): WritableAtom<ZkLoginState | null>;
|
|
13
|
+
get sessionContextByNetwork(): Map<Experimental_HaneulClientTypes.Network, EnokiSessionContext>;
|
|
14
|
+
getSessionContext(network: Experimental_HaneulClientTypes.Network): EnokiSessionContext;
|
|
15
|
+
logout(): Promise<void>;
|
|
16
|
+
setSession(context: EnokiSessionContext, newValue: ZkLoginSession | null): Promise<void>;
|
|
17
|
+
getSession({ $zkLoginSession, idbStore }: EnokiSessionContext): Promise<ZkLoginSession | null>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
27
|
+
var state_exports = {};
|
|
28
|
+
__export(state_exports, {
|
|
29
|
+
EnokiWalletState: () => EnokiWalletState
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(state_exports);
|
|
32
|
+
var import_idb_keyval = require("idb-keyval");
|
|
33
|
+
var import_nanostores = require("nanostores");
|
|
34
|
+
var import_encryption = require("../encryption.js");
|
|
35
|
+
var _encryption, _encryptionKey, _stateStore, _sessionContextByNetwork, _zkLoginState, _EnokiWalletState_instances, createZkLoginState_fn;
|
|
36
|
+
const sessionKey = "zklogin-session";
|
|
37
|
+
const stateKey = "zklogin-state";
|
|
38
|
+
class EnokiWalletState {
|
|
39
|
+
constructor(config) {
|
|
40
|
+
__privateAdd(this, _EnokiWalletState_instances);
|
|
41
|
+
__privateAdd(this, _encryption);
|
|
42
|
+
__privateAdd(this, _encryptionKey);
|
|
43
|
+
__privateAdd(this, _stateStore);
|
|
44
|
+
__privateAdd(this, _sessionContextByNetwork);
|
|
45
|
+
__privateAdd(this, _zkLoginState);
|
|
46
|
+
__privateSet(this, _encryptionKey, config.apiKey);
|
|
47
|
+
__privateSet(this, _encryption, (0, import_encryption.createDefaultEncryption)());
|
|
48
|
+
__privateSet(this, _stateStore, (0, import_idb_keyval.createStore)(`${config.apiKey}_${config.clientId}`, "enoki"));
|
|
49
|
+
__privateSet(this, _zkLoginState, __privateMethod(this, _EnokiWalletState_instances, createZkLoginState_fn).call(this));
|
|
50
|
+
__privateSet(this, _sessionContextByNetwork, config.clients.reduce((accumulator, client) => {
|
|
51
|
+
const network = client.network;
|
|
52
|
+
const idbStore = (0, import_idb_keyval.createStore)(`${config.apiKey}_${network}_${config.clientId}`, "enoki");
|
|
53
|
+
const sessionContext = {
|
|
54
|
+
$zkLoginSession: (0, import_nanostores.atom)({ initialized: false, value: null }),
|
|
55
|
+
client,
|
|
56
|
+
idbStore
|
|
57
|
+
};
|
|
58
|
+
(0, import_nanostores.onMount)(sessionContext.$zkLoginSession, () => {
|
|
59
|
+
this.getSession(sessionContext);
|
|
60
|
+
});
|
|
61
|
+
return accumulator.set(network, sessionContext);
|
|
62
|
+
}, /* @__PURE__ */ new Map()));
|
|
63
|
+
}
|
|
64
|
+
get zkLoginState() {
|
|
65
|
+
return __privateGet(this, _zkLoginState);
|
|
66
|
+
}
|
|
67
|
+
get sessionContextByNetwork() {
|
|
68
|
+
return __privateGet(this, _sessionContextByNetwork);
|
|
69
|
+
}
|
|
70
|
+
getSessionContext(network) {
|
|
71
|
+
const context = __privateGet(this, _sessionContextByNetwork).get(network);
|
|
72
|
+
if (!context) {
|
|
73
|
+
throw new Error(`The network ${network} isn't supported.`);
|
|
74
|
+
}
|
|
75
|
+
return context;
|
|
76
|
+
}
|
|
77
|
+
async logout() {
|
|
78
|
+
__privateGet(this, _zkLoginState).set(null);
|
|
79
|
+
await (0, import_idb_keyval.clear)(__privateGet(this, _stateStore));
|
|
80
|
+
for (const context of __privateGet(this, _sessionContextByNetwork).values()) {
|
|
81
|
+
await this.setSession(context, null);
|
|
82
|
+
await (0, import_idb_keyval.clear)(context.idbStore);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async setSession(context, newValue) {
|
|
86
|
+
if (newValue) {
|
|
87
|
+
const storedValue = await __privateGet(this, _encryption).encrypt(
|
|
88
|
+
__privateGet(this, _encryptionKey),
|
|
89
|
+
JSON.stringify(newValue)
|
|
90
|
+
);
|
|
91
|
+
await (0, import_idb_keyval.set)(sessionKey, storedValue, context.idbStore);
|
|
92
|
+
} else {
|
|
93
|
+
await (0, import_idb_keyval.del)(sessionKey, context.idbStore);
|
|
94
|
+
}
|
|
95
|
+
context.$zkLoginSession.set({ initialized: true, value: newValue });
|
|
96
|
+
}
|
|
97
|
+
async getSession({ $zkLoginSession, idbStore }) {
|
|
98
|
+
if ($zkLoginSession.get().initialized) {
|
|
99
|
+
return $zkLoginSession.get().value;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const storedValue = await (0, import_idb_keyval.get)(sessionKey, idbStore);
|
|
103
|
+
if (!storedValue) return null;
|
|
104
|
+
const state = JSON.parse(
|
|
105
|
+
await __privateGet(this, _encryption).decrypt(__privateGet(this, _encryptionKey), storedValue)
|
|
106
|
+
);
|
|
107
|
+
if (state?.expiresAt && Date.now() > state.expiresAt) {
|
|
108
|
+
await this.logout();
|
|
109
|
+
} else {
|
|
110
|
+
$zkLoginSession.set({ initialized: true, value: state });
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
$zkLoginSession.set({ initialized: true, value: null });
|
|
114
|
+
}
|
|
115
|
+
return $zkLoginSession.get().value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_encryption = new WeakMap();
|
|
119
|
+
_encryptionKey = new WeakMap();
|
|
120
|
+
_stateStore = new WeakMap();
|
|
121
|
+
_sessionContextByNetwork = new WeakMap();
|
|
122
|
+
_zkLoginState = new WeakMap();
|
|
123
|
+
_EnokiWalletState_instances = new WeakSet();
|
|
124
|
+
createZkLoginState_fn = function() {
|
|
125
|
+
const $zkLoginState = (0, import_nanostores.atom)(null);
|
|
126
|
+
(0, import_nanostores.onMount)($zkLoginState, () => {
|
|
127
|
+
(0, import_nanostores.task)(async () => {
|
|
128
|
+
try {
|
|
129
|
+
const rawStoredValue = await (0, import_idb_keyval.get)(stateKey, __privateGet(this, _stateStore));
|
|
130
|
+
if (rawStoredValue) {
|
|
131
|
+
$zkLoginState.set(JSON.parse(rawStoredValue));
|
|
132
|
+
}
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
(0, import_nanostores.onSet)($zkLoginState, ({ newValue }) => {
|
|
138
|
+
(0, import_idb_keyval.set)(stateKey, JSON.stringify(newValue), __privateGet(this, _stateStore));
|
|
139
|
+
});
|
|
140
|
+
return $zkLoginState;
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/wallet/state.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseStore } from 'idb-keyval';\nimport { clear, createStore, del, get, set } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\nimport { atom, onMount, onSet, task } from 'nanostores';\n\nimport type { Encryption } from '../encryption.js';\nimport { createDefaultEncryption } from '../encryption.js';\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { ClientWithCoreApi, Experimental_HaneulClientTypes } from '@haneullabs/haneul/experimental';\n\nimport type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';\n\nexport type EnokiWalletStateConfig = EnokiClientConfig & {\n\tclients: ClientWithCoreApi[];\n\tclientId: string;\n};\n\nconst sessionKey = 'zklogin-session';\n\nconst stateKey = 'zklogin-state';\n\nexport class EnokiWalletState {\n\t#encryption: Encryption;\n\t#encryptionKey: string;\n\n\t#stateStore: UseStore;\n\t#sessionContextByNetwork: Map<Experimental_HaneulClientTypes.Network, EnokiSessionContext>;\n\t#zkLoginState: WritableAtom<ZkLoginState | null>;\n\n\tconstructor(config: EnokiWalletStateConfig) {\n\t\tthis.#encryptionKey = config.apiKey;\n\t\tthis.#encryption = createDefaultEncryption();\n\n\t\tthis.#stateStore = createStore(`${config.apiKey}_${config.clientId}`, 'enoki');\n\t\tthis.#zkLoginState = this.#createZkLoginState();\n\n\t\tthis.#sessionContextByNetwork = config.clients.reduce((accumulator, client) => {\n\t\t\tconst network = client.network;\n\t\t\tconst idbStore = createStore(`${config.apiKey}_${network}_${config.clientId}`, 'enoki');\n\n\t\t\tconst sessionContext: EnokiSessionContext = {\n\t\t\t\t$zkLoginSession: atom({ initialized: false, value: null }),\n\t\t\t\tclient,\n\t\t\t\tidbStore,\n\t\t\t};\n\n\t\t\tonMount(sessionContext.$zkLoginSession, () => {\n\t\t\t\tthis.getSession(sessionContext);\n\t\t\t});\n\n\t\t\treturn accumulator.set(network, sessionContext);\n\t\t}, new Map());\n\t}\n\n\tget zkLoginState() {\n\t\treturn this.#zkLoginState;\n\t}\n\n\tget sessionContextByNetwork() {\n\t\treturn this.#sessionContextByNetwork;\n\t}\n\n\tgetSessionContext(network: Experimental_HaneulClientTypes.Network) {\n\t\tconst context = this.#sessionContextByNetwork.get(network);\n\t\tif (!context) {\n\t\t\tthrow new Error(`The network ${network} isn't supported.`);\n\t\t}\n\n\t\treturn context;\n\t}\n\n\tasync logout() {\n\t\tthis.#zkLoginState.set(null);\n\t\tawait clear(this.#stateStore);\n\n\t\tfor (const context of this.#sessionContextByNetwork.values()) {\n\t\t\tawait this.setSession(context, null);\n\t\t\tawait clear(context.idbStore);\n\t\t}\n\t}\n\n\tasync setSession(context: EnokiSessionContext, newValue: ZkLoginSession | null) {\n\t\tif (newValue) {\n\t\t\tconst storedValue = await this.#encryption.encrypt(\n\t\t\t\tthis.#encryptionKey,\n\t\t\t\tJSON.stringify(newValue),\n\t\t\t);\n\n\t\t\tawait set(sessionKey, storedValue, context.idbStore);\n\t\t} else {\n\t\t\tawait del(sessionKey, context.idbStore);\n\t\t}\n\n\t\tcontext.$zkLoginSession.set({ initialized: true, value: newValue });\n\t}\n\n\tasync getSession({ $zkLoginSession, idbStore }: EnokiSessionContext) {\n\t\tif ($zkLoginSession.get().initialized) {\n\t\t\treturn $zkLoginSession.get().value;\n\t\t}\n\n\t\ttry {\n\t\t\tconst storedValue = await get(sessionKey, idbStore);\n\t\t\tif (!storedValue) return null;\n\n\t\t\tconst state: ZkLoginSession = JSON.parse(\n\t\t\t\tawait this.#encryption.decrypt(this.#encryptionKey, storedValue),\n\t\t\t);\n\n\t\t\tif (state?.expiresAt && Date.now() > state.expiresAt) {\n\t\t\t\tawait this.logout();\n\t\t\t} else {\n\t\t\t\t$zkLoginSession.set({ initialized: true, value: state });\n\t\t\t}\n\t\t} catch {\n\t\t\t$zkLoginSession.set({ initialized: true, value: null });\n\t\t}\n\n\t\treturn $zkLoginSession.get().value;\n\t}\n\n\t#createZkLoginState() {\n\t\tconst $zkLoginState = atom<ZkLoginState | null>(null);\n\n\t\tonMount($zkLoginState, () => {\n\t\t\ttask(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst rawStoredValue = await get<string>(stateKey, this.#stateStore);\n\t\t\t\t\tif (rawStoredValue) {\n\t\t\t\t\t\t$zkLoginState.set(JSON.parse(rawStoredValue));\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore errors\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tonSet($zkLoginState, ({ newValue }) => {\n\t\t\tset(stateKey, JSON.stringify(newValue), this.#stateStore);\n\t\t});\n\n\t\treturn $zkLoginState;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { HaneulClient } from '@haneullabs/haneul/client';
|
|
2
|
+
import type { StandardEventsListeners, Wallet } from '@haneullabs/wallet-standard';
|
|
3
|
+
import type { EnokiClientConfig } from '../EnokiClient/index.js';
|
|
4
|
+
import type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';
|
|
5
|
+
import type { ClientWithCoreApi, Experimental_HaneulClientTypes } from '@haneullabs/haneul/experimental';
|
|
6
|
+
import type { ZkLoginSignatureInputs } from '@haneullabs/haneul/zklogin';
|
|
7
|
+
import type { UseStore } from 'idb-keyval';
|
|
8
|
+
import type { WritableAtom } from 'nanostores';
|
|
9
|
+
export type WalletEventsMap = {
|
|
10
|
+
[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];
|
|
11
|
+
};
|
|
12
|
+
export type ZkLoginState = {
|
|
13
|
+
address: string;
|
|
14
|
+
publicKey: string;
|
|
15
|
+
};
|
|
16
|
+
export type ZkLoginSession = {
|
|
17
|
+
maxEpoch: number;
|
|
18
|
+
randomness: string;
|
|
19
|
+
expiresAt: number;
|
|
20
|
+
jwt?: string;
|
|
21
|
+
proof?: ZkLoginSignatureInputs;
|
|
22
|
+
};
|
|
23
|
+
export type EnokiSessionContext = {
|
|
24
|
+
idbStore: UseStore;
|
|
25
|
+
client: ClientWithCoreApi;
|
|
26
|
+
$zkLoginSession: WritableAtom<{
|
|
27
|
+
initialized: boolean;
|
|
28
|
+
value: ZkLoginSession | null;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
type ClientConfig = {
|
|
32
|
+
/**
|
|
33
|
+
* A list of client instances to use when building and executing transactions.
|
|
34
|
+
*/
|
|
35
|
+
clients: ClientWithCoreApi[];
|
|
36
|
+
/**
|
|
37
|
+
* A function that returns the current network that the application is acting on.
|
|
38
|
+
*/
|
|
39
|
+
getCurrentNetwork: () => Experimental_HaneulClientTypes.Network;
|
|
40
|
+
};
|
|
41
|
+
export type EnokiWalletOptions = {
|
|
42
|
+
/**
|
|
43
|
+
* The window features to use when opening the authorization popup.
|
|
44
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures
|
|
45
|
+
*/
|
|
46
|
+
windowFeatures?: string | (() => string);
|
|
47
|
+
/**
|
|
48
|
+
* The authentication provider to register the wallet for.
|
|
49
|
+
*/
|
|
50
|
+
provider: AuthProvider;
|
|
51
|
+
} & AuthProviderOptions & EnokiClientConfig & ClientConfig & Pick<Wallet, 'name' | 'icon'>;
|
|
52
|
+
export type AuthProviderOptions = {
|
|
53
|
+
/**
|
|
54
|
+
* The OAuth client ID.
|
|
55
|
+
*/
|
|
56
|
+
clientId: string;
|
|
57
|
+
/**
|
|
58
|
+
* The URL to redirect to after authorization.
|
|
59
|
+
*/
|
|
60
|
+
redirectUrl?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Extra parameters to include in the authorization URL.
|
|
63
|
+
*/
|
|
64
|
+
extraParams?: Record<string, string> | (() => Record<string, string>);
|
|
65
|
+
};
|
|
66
|
+
export type RegisterEnokiWalletsOptions = {
|
|
67
|
+
/**
|
|
68
|
+
* Configuration for each OAuth provider.
|
|
69
|
+
*/
|
|
70
|
+
providers: Partial<Record<AuthProvider, AuthProviderOptions>>;
|
|
71
|
+
} & Pick<EnokiWalletOptions, 'apiKey' | 'apiUrl' | 'additionalEpochs' | 'windowFeatures'> & (ClientConfig | {
|
|
72
|
+
/**
|
|
73
|
+
* The HaneulClient instance to use when building and executing transactions.
|
|
74
|
+
*/
|
|
75
|
+
client: HaneulClient;
|
|
76
|
+
/**
|
|
77
|
+
* The network to use when building and executing transactions.
|
|
78
|
+
* @default 'mainnet'
|
|
79
|
+
*/
|
|
80
|
+
network?: EnokiNetwork;
|
|
81
|
+
});
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/wallet/types.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { HaneulClient } from '@haneullabs/haneul/client';\nimport type { StandardEventsListeners, Wallet } from '@haneullabs/wallet-standard';\n\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\nimport type { ClientWithCoreApi, Experimental_HaneulClientTypes } from '@haneullabs/haneul/experimental';\nimport type { ZkLoginSignatureInputs } from '@haneullabs/haneul/zklogin';\nimport type { UseStore } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\n\nexport type WalletEventsMap = {\n\t[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];\n};\n\nexport type ZkLoginState = {\n\taddress: string;\n\tpublicKey: string;\n};\n\nexport type ZkLoginSession = {\n\tmaxEpoch: number;\n\trandomness: string;\n\texpiresAt: number;\n\tjwt?: string;\n\tproof?: ZkLoginSignatureInputs;\n};\n\nexport type EnokiSessionContext = {\n\tidbStore: UseStore;\n\tclient: ClientWithCoreApi;\n\t$zkLoginSession: WritableAtom<{ initialized: boolean; value: ZkLoginSession | null }>;\n};\n\ntype ClientConfig = {\n\t/**\n\t * A list of client instances to use when building and executing transactions.\n\t */\n\tclients: ClientWithCoreApi[];\n\n\t/**\n\t * A function that returns the current network that the application is acting on.\n\t */\n\tgetCurrentNetwork: () => Experimental_HaneulClientTypes.Network;\n};\n\nexport type EnokiWalletOptions = {\n\t/**\n\t * The window features to use when opening the authorization popup.\n\t * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures\n\t */\n\twindowFeatures?: string | (() => string);\n\n\t/**\n\t * The authentication provider to register the wallet for.\n\t */\n\tprovider: AuthProvider;\n} & AuthProviderOptions &\n\tEnokiClientConfig &\n\tClientConfig &\n\tPick<Wallet, 'name' | 'icon'>;\n\nexport type AuthProviderOptions = {\n\t/**\n\t * The OAuth client ID.\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URL to redirect to after authorization.\n\t */\n\tredirectUrl?: string;\n\n\t/**\n\t * Extra parameters to include in the authorization URL.\n\t */\n\textraParams?: Record<string, string> | (() => Record<string, string>);\n};\n\nexport type RegisterEnokiWalletsOptions = {\n\t/**\n\t * Configuration for each OAuth provider.\n\t */\n\tproviders: Partial<Record<AuthProvider, AuthProviderOptions>>;\n} & Pick<EnokiWalletOptions, 'apiKey' | 'apiUrl' | 'additionalEpochs' | 'windowFeatures'> &\n\t(\n\t\t| ClientConfig\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * The HaneulClient instance to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclient: HaneulClient;\n\n\t\t\t\t/**\n\t\t\t\t * The network to use when building and executing transactions.\n\t\t\t\t * @default 'mainnet'\n\t\t\t\t */\n\t\t\t\tnetwork?: EnokiNetwork;\n\t\t }\n\t);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Wallet } from '@haneullabs/wallet-standard';
|
|
2
|
+
import type { UiWallet } from '@wallet-standard/ui';
|
|
3
|
+
import type { EnokiWallet } from './wallet.js';
|
|
4
|
+
import type { EnokiGetSessionInput } from './features.js';
|
|
5
|
+
export declare function isEnokiWallet(wallet: UiWallet): boolean;
|
|
6
|
+
export declare function isEnokiWallet(wallet: Wallet): wallet is EnokiWallet;
|
|
7
|
+
export declare function getWalletMetadata(wallet: Wallet | UiWallet): import("./features.js").EnokiGetMetadataOutput | null;
|
|
8
|
+
export declare function getSession(wallet: Wallet | UiWallet, input?: EnokiGetSessionInput): Promise<import("./features.js").EnokiGetSessionOutput>;
|
|
9
|
+
export declare function isGoogleWallet(wallet: Wallet | UiWallet): boolean;
|
|
10
|
+
export declare function isTwitchWallet(wallet: Wallet | UiWallet): boolean;
|
|
11
|
+
export declare function isFacebookWallet(wallet: Wallet | UiWallet): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
getSession: () => getSession,
|
|
22
|
+
getWalletMetadata: () => getWalletMetadata,
|
|
23
|
+
isEnokiWallet: () => isEnokiWallet,
|
|
24
|
+
isFacebookWallet: () => isFacebookWallet,
|
|
25
|
+
isGoogleWallet: () => isGoogleWallet,
|
|
26
|
+
isTwitchWallet: () => isTwitchWallet
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
var import_ui = require("@wallet-standard/ui");
|
|
30
|
+
var import_features = require("./features.js");
|
|
31
|
+
function isEnokiWallet(wallet) {
|
|
32
|
+
if (isWalletHandle(wallet)) {
|
|
33
|
+
return wallet.features.includes(import_features.EnokiGetMetadata);
|
|
34
|
+
}
|
|
35
|
+
return import_features.EnokiGetMetadata in wallet.features;
|
|
36
|
+
}
|
|
37
|
+
function getWalletMetadata(wallet) {
|
|
38
|
+
if (isWalletHandle(wallet)) {
|
|
39
|
+
try {
|
|
40
|
+
const { getMetadata } = (0, import_ui.getWalletFeature)(
|
|
41
|
+
wallet,
|
|
42
|
+
import_features.EnokiGetMetadata
|
|
43
|
+
);
|
|
44
|
+
return getMetadata();
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
} else if (import_features.EnokiGetMetadata in wallet.features) {
|
|
49
|
+
const walletWithFeature = wallet;
|
|
50
|
+
return walletWithFeature.features[import_features.EnokiGetMetadata].getMetadata();
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
async function getSession(wallet, input) {
|
|
55
|
+
if (isWalletHandle(wallet)) {
|
|
56
|
+
try {
|
|
57
|
+
const { getSession: getSession2 } = (0, import_ui.getWalletFeature)(
|
|
58
|
+
wallet,
|
|
59
|
+
import_features.EnokiGetSession
|
|
60
|
+
);
|
|
61
|
+
return await getSession2(input);
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
} else if (import_features.EnokiGetSession in wallet.features) {
|
|
66
|
+
const walletWithFeature = wallet;
|
|
67
|
+
return await walletWithFeature.features[import_features.EnokiGetSession].getSession(input);
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function isGoogleWallet(wallet) {
|
|
72
|
+
return getWalletMetadata(wallet)?.provider === "google";
|
|
73
|
+
}
|
|
74
|
+
function isTwitchWallet(wallet) {
|
|
75
|
+
return getWalletMetadata(wallet)?.provider === "twitch";
|
|
76
|
+
}
|
|
77
|
+
function isFacebookWallet(wallet) {
|
|
78
|
+
return getWalletMetadata(wallet)?.provider === "facebook";
|
|
79
|
+
}
|
|
80
|
+
function isWalletHandle(wallet) {
|
|
81
|
+
return Array.isArray(wallet.features);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/wallet/utils.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet, WalletWithFeatures } from '@haneullabs/wallet-standard';\nimport type { UiWallet } from '@wallet-standard/ui';\nimport { getWalletFeature } from '@wallet-standard/ui';\nimport type { EnokiWallet } from './wallet.js';\nimport type {\n\tEnokiGetMetadataFeature,\n\tEnokiGetSessionFeature,\n\tEnokiGetSessionInput,\n} from './features.js';\nimport { EnokiGetMetadata, EnokiGetSession } from './features.js';\n\nexport function isEnokiWallet(wallet: UiWallet): boolean;\nexport function isEnokiWallet(wallet: Wallet): wallet is EnokiWallet;\nexport function isEnokiWallet(wallet: Wallet | UiWallet) {\n\tif (isWalletHandle(wallet)) {\n\t\treturn wallet.features.includes(EnokiGetMetadata);\n\t}\n\treturn EnokiGetMetadata in wallet.features;\n}\n\nexport function getWalletMetadata(wallet: Wallet | UiWallet) {\n\tif (isWalletHandle(wallet)) {\n\t\ttry {\n\t\t\tconst { getMetadata } = getWalletFeature(\n\t\t\t\twallet,\n\t\t\t\tEnokiGetMetadata,\n\t\t\t) as EnokiGetMetadataFeature[typeof EnokiGetMetadata];\n\n\t\t\treturn getMetadata();\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else if (EnokiGetMetadata in wallet.features) {\n\t\tconst walletWithFeature = wallet as WalletWithFeatures<EnokiGetMetadataFeature>;\n\t\treturn walletWithFeature.features[EnokiGetMetadata].getMetadata();\n\t}\n\treturn null;\n}\n\nexport async function getSession(wallet: Wallet | UiWallet, input?: EnokiGetSessionInput) {\n\tif (isWalletHandle(wallet)) {\n\t\ttry {\n\t\t\tconst { getSession } = getWalletFeature(\n\t\t\t\twallet,\n\t\t\t\tEnokiGetSession,\n\t\t\t) as EnokiGetSessionFeature[typeof EnokiGetSession];\n\n\t\t\treturn await getSession(input);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else if (EnokiGetSession in wallet.features) {\n\t\tconst walletWithFeature = wallet as WalletWithFeatures<EnokiGetSessionFeature>;\n\t\treturn await walletWithFeature.features[EnokiGetSession].getSession(input);\n\t}\n\treturn null;\n}\n\nexport function isGoogleWallet(wallet: Wallet | UiWallet) {\n\treturn getWalletMetadata(wallet)?.provider === 'google';\n}\n\nexport function isTwitchWallet(wallet: Wallet | UiWallet) {\n\treturn getWalletMetadata(wallet)?.provider === 'twitch';\n}\n\nexport function isFacebookWallet(wallet: Wallet | UiWallet) {\n\treturn getWalletMetadata(wallet)?.provider === 'facebook';\n}\n\nfunction isWalletHandle(wallet: UiWallet | Wallet): wallet is UiWallet {\n\t// TypeScript doesn't properly narrow readonly arrays:\n\t// https://github.com/microsoft/TypeScript/issues/1700\n\treturn Array.isArray(wallet.features);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,gBAAiC;AAOjC,sBAAkD;AAI3C,SAAS,cAAc,QAA2B;AACxD,MAAI,eAAe,MAAM,GAAG;AAC3B,WAAO,OAAO,SAAS,SAAS,gCAAgB;AAAA,EACjD;AACA,SAAO,oCAAoB,OAAO;AACnC;AAEO,SAAS,kBAAkB,QAA2B;AAC5D,MAAI,eAAe,MAAM,GAAG;AAC3B,QAAI;AACH,YAAM,EAAE,YAAY,QAAI;AAAA,QACvB;AAAA,QACA;AAAA,MACD;AAEA,aAAO,YAAY;AAAA,IACpB,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD,WAAW,oCAAoB,OAAO,UAAU;AAC/C,UAAM,oBAAoB;AAC1B,WAAO,kBAAkB,SAAS,gCAAgB,EAAE,YAAY;AAAA,EACjE;AACA,SAAO;AACR;AAEA,eAAsB,WAAW,QAA2B,OAA8B;AACzF,MAAI,eAAe,MAAM,GAAG;AAC3B,QAAI;AACH,YAAM,EAAE,YAAAA,YAAW,QAAI;AAAA,QACtB;AAAA,QACA;AAAA,MACD;AAEA,aAAO,MAAMA,YAAW,KAAK;AAAA,IAC9B,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD,WAAW,mCAAmB,OAAO,UAAU;AAC9C,UAAM,oBAAoB;AAC1B,WAAO,MAAM,kBAAkB,SAAS,+BAAe,EAAE,WAAW,KAAK;AAAA,EAC1E;AACA,SAAO;AACR;AAEO,SAAS,eAAe,QAA2B;AACzD,SAAO,kBAAkB,MAAM,GAAG,aAAa;AAChD;AAEO,SAAS,eAAe,QAA2B;AACzD,SAAO,kBAAkB,MAAM,GAAG,aAAa;AAChD;AAEO,SAAS,iBAAiB,QAA2B;AAC3D,SAAO,kBAAkB,MAAM,GAAG,aAAa;AAChD;AAEA,SAAS,eAAe,QAA+C;AAGtE,SAAO,MAAM,QAAQ,OAAO,QAAQ;AACrC;",
|
|
6
|
+
"names": ["getSession"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, HaneulSignAndExecuteTransactionFeature, HaneulSignPersonalMessageFeature, HaneulSignTransactionFeature, Wallet } from '@haneullabs/wallet-standard';
|
|
2
|
+
import { ReadonlyWalletAccount } from '@haneullabs/wallet-standard';
|
|
3
|
+
import type { AuthProvider } from '../EnokiClient/type.js';
|
|
4
|
+
import type { EnokiWalletOptions } from './types.js';
|
|
5
|
+
import type { EnokiGetMetadataFeature, EnokiGetSessionFeature } from './features.js';
|
|
6
|
+
export declare class EnokiWallet implements Wallet {
|
|
7
|
+
#private;
|
|
8
|
+
get name(): string;
|
|
9
|
+
get provider(): AuthProvider;
|
|
10
|
+
get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}`;
|
|
11
|
+
get version(): "1.0.0";
|
|
12
|
+
get chains(): `sui:${string & {}}`[];
|
|
13
|
+
get accounts(): ReadonlyWalletAccount[];
|
|
14
|
+
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & HaneulSignTransactionFeature & HaneulSignAndExecuteTransactionFeature & HaneulSignPersonalMessageFeature & EnokiGetMetadataFeature & EnokiGetSessionFeature;
|
|
15
|
+
constructor({ name, icon, provider, clientId, redirectUrl, extraParams, windowFeatures, getCurrentNetwork, apiKey, apiUrl, additionalEpochs, clients, }: EnokiWalletOptions);
|
|
16
|
+
}
|