@mysten/enoki 0.7.0 → 0.8.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 +17 -0
- package/dist/cjs/EnokiFlow.js +1 -1
- package/dist/cjs/EnokiFlow.js.map +2 -2
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +2 -2
- 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/register.d.ts +7 -0
- package/dist/cjs/wallet/register.js +67 -0
- package/dist/cjs/wallet/register.js.map +7 -0
- package/dist/cjs/wallet/state.d.ts +12 -37
- package/dist/cjs/wallet/state.js +79 -198
- package/dist/cjs/wallet/state.js.map +2 -2
- package/dist/cjs/wallet/types.d.ts +61 -22
- package/dist/cjs/wallet/types.js.map +1 -1
- package/dist/cjs/wallet/utils.d.ts +1 -1
- package/dist/cjs/wallet/utils.js.map +1 -1
- package/dist/cjs/wallet/{index.d.ts → wallet.d.ts} +3 -21
- package/dist/cjs/wallet/wallet.js +424 -0
- package/dist/cjs/wallet/wallet.js.map +7 -0
- package/dist/esm/EnokiFlow.js +1 -1
- package/dist/esm/EnokiFlow.js.map +2 -2
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +2 -2
- 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/register.d.ts +7 -0
- package/dist/esm/wallet/register.js +47 -0
- package/dist/esm/wallet/register.js.map +7 -0
- package/dist/esm/wallet/state.d.ts +12 -37
- package/dist/esm/wallet/state.js +81 -200
- package/dist/esm/wallet/state.js.map +2 -2
- package/dist/esm/wallet/types.d.ts +61 -22
- package/dist/esm/wallet/utils.d.ts +1 -1
- package/dist/esm/wallet/utils.js.map +1 -1
- package/dist/esm/wallet/{index.d.ts → wallet.d.ts} +3 -21
- package/dist/esm/wallet/wallet.js +402 -0
- package/dist/esm/wallet/wallet.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/cjs/wallet/index.js +0 -342
- package/dist/cjs/wallet/index.js.map +0 -7
- package/dist/esm/wallet/index.js +0 -321
- package/dist/esm/wallet/index.js.map +0 -7
package/dist/cjs/wallet/state.js
CHANGED
|
@@ -26,140 +26,83 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
26
26
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
27
27
|
var state_exports = {};
|
|
28
28
|
__export(state_exports, {
|
|
29
|
-
|
|
29
|
+
EnokiWalletState: () => EnokiWalletState
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(state_exports);
|
|
32
|
-
var import_webcrypto = require("@mysten/signers/webcrypto");
|
|
33
|
-
var import_zklogin = require("@mysten/sui/zklogin");
|
|
34
32
|
var import_idb_keyval = require("idb-keyval");
|
|
35
33
|
var import_nanostores = require("nanostores");
|
|
36
34
|
var import_encryption = require("../encryption.js");
|
|
37
|
-
var import_EnokiClient = require("../EnokiClient/index.js");
|
|
38
|
-
var import_EnokiKeypair = require("../EnokiKeypair.js");
|
|
39
35
|
var import_stores = require("../stores.js");
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
STATE: `@enoki/flow/state/${apiKey}/${network}`,
|
|
43
|
-
SESSION: `@enoki/flow/session/${apiKey}/${network}`
|
|
44
|
-
});
|
|
45
|
-
class INTERNAL_ONLY_EnokiFlow {
|
|
36
|
+
var _encryption, _encryptionKey, _sessionStore, _stateStorageKey, _sessionContextByNetwork, _zkLoginState, _EnokiWalletState_instances, createZkLoginState_fn;
|
|
37
|
+
class EnokiWalletState {
|
|
46
38
|
constructor(config) {
|
|
47
|
-
__privateAdd(this,
|
|
48
|
-
__privateAdd(this, _storageKeys);
|
|
49
|
-
__privateAdd(this, _enokiClient);
|
|
50
|
-
__privateAdd(this, _network);
|
|
39
|
+
__privateAdd(this, _EnokiWalletState_instances);
|
|
51
40
|
__privateAdd(this, _encryption);
|
|
52
41
|
__privateAdd(this, _encryptionKey);
|
|
53
|
-
__privateAdd(this,
|
|
54
|
-
__privateAdd(this,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
apiUrl: config.apiUrl
|
|
58
|
-
}));
|
|
59
|
-
__privateSet(this, _network, config.network);
|
|
42
|
+
__privateAdd(this, _sessionStore);
|
|
43
|
+
__privateAdd(this, _stateStorageKey);
|
|
44
|
+
__privateAdd(this, _sessionContextByNetwork);
|
|
45
|
+
__privateAdd(this, _zkLoginState);
|
|
60
46
|
__privateSet(this, _encryptionKey, config.apiKey);
|
|
61
47
|
__privateSet(this, _encryption, (0, import_encryption.createDefaultEncryption)());
|
|
62
|
-
__privateSet(this,
|
|
63
|
-
__privateSet(this,
|
|
64
|
-
__privateSet(this,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
48
|
+
__privateSet(this, _sessionStore, (0, import_stores.createSessionStorage)());
|
|
49
|
+
__privateSet(this, _stateStorageKey, `@enoki/flow/state/${config.apiKey}/${config.clientId}`);
|
|
50
|
+
__privateSet(this, _zkLoginState, __privateMethod(this, _EnokiWalletState_instances, createZkLoginState_fn).call(this));
|
|
51
|
+
__privateSet(this, _sessionContextByNetwork, config.clients.reduce((accumulator, client) => {
|
|
52
|
+
const network = client.network;
|
|
53
|
+
const storageKey = `@enoki/flow/session/${config.apiKey}/${network}/${config.clientId}`;
|
|
54
|
+
const idbStore = (0, import_idb_keyval.createStore)(`${config.apiKey}_${network}_${config.clientId}`, "enoki");
|
|
55
|
+
const sessionContext = {
|
|
56
|
+
$zkLoginSession: (0, import_nanostores.atom)({ initialized: false, value: null }),
|
|
57
|
+
client,
|
|
58
|
+
storageKey,
|
|
59
|
+
idbStore
|
|
60
|
+
};
|
|
61
|
+
(0, import_nanostores.onMount)(sessionContext.$zkLoginSession, () => {
|
|
62
|
+
this.getSession(sessionContext);
|
|
63
|
+
});
|
|
64
|
+
return accumulator.set(network, sessionContext);
|
|
65
|
+
}, /* @__PURE__ */ new Map()));
|
|
81
66
|
}
|
|
82
|
-
get
|
|
83
|
-
return __privateGet(this,
|
|
67
|
+
get zkLoginState() {
|
|
68
|
+
return __privateGet(this, _zkLoginState);
|
|
84
69
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...input.extraParams,
|
|
93
|
-
nonce,
|
|
94
|
-
client_id: input.clientId,
|
|
95
|
-
redirect_uri: input.redirectUrl,
|
|
96
|
-
response_type: "id_token",
|
|
97
|
-
// TODO: Eventually fetch the scopes for this client ID from the Enoki service:
|
|
98
|
-
scope: [
|
|
99
|
-
"openid",
|
|
100
|
-
// Merge the requested scopes in with the required openid scopes:
|
|
101
|
-
...input.extraParams?.scope ? input.extraParams.scope.split(" ") : []
|
|
102
|
-
].filter(Boolean).join(" ")
|
|
103
|
-
});
|
|
104
|
-
let oauthUrl;
|
|
105
|
-
switch (input.provider) {
|
|
106
|
-
case "google": {
|
|
107
|
-
oauthUrl = `https://accounts.google.com/o/oauth2/v2/auth?${params}`;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
case "facebook": {
|
|
111
|
-
oauthUrl = `https://www.facebook.com/v17.0/dialog/oauth?${params}`;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
case "twitch": {
|
|
115
|
-
params.set("force_verify", "true");
|
|
116
|
-
oauthUrl = `https://id.twitch.tv/oauth2/authorize?${params}`;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
default:
|
|
120
|
-
throw new Error(`Invalid provider: ${input.provider}`);
|
|
70
|
+
get sessionContextByNetwork() {
|
|
71
|
+
return __privateGet(this, _sessionContextByNetwork);
|
|
72
|
+
}
|
|
73
|
+
getSessionContext(network) {
|
|
74
|
+
const context = __privateGet(this, _sessionContextByNetwork).get(network);
|
|
75
|
+
if (!context) {
|
|
76
|
+
throw new Error(`The network ${network} isn't supported.`);
|
|
121
77
|
}
|
|
122
|
-
|
|
123
|
-
await (0, import_idb_keyval.set)("ephemeralKeyPair", ephemeralKeyPair.export(), __privateGet(this, _idbStore));
|
|
124
|
-
await __privateMethod(this, _INTERNAL_ONLY_EnokiFlow_instances, setSession_fn).call(this, {
|
|
125
|
-
expiresAt: estimatedExpiration,
|
|
126
|
-
maxEpoch,
|
|
127
|
-
randomness
|
|
128
|
-
});
|
|
129
|
-
return oauthUrl;
|
|
78
|
+
return context;
|
|
130
79
|
}
|
|
131
|
-
async
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
80
|
+
async logout() {
|
|
81
|
+
__privateGet(this, _zkLoginState).set({});
|
|
82
|
+
__privateGet(this, _sessionStore).delete(__privateGet(this, _stateStorageKey));
|
|
83
|
+
for (const state of __privateGet(this, _sessionContextByNetwork).values()) {
|
|
84
|
+
await (0, import_idb_keyval.clear)(state.idbStore);
|
|
85
|
+
await this.setSession(state, null);
|
|
138
86
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
87
|
+
}
|
|
88
|
+
async setSession(state, newValue) {
|
|
89
|
+
if (newValue) {
|
|
90
|
+
const storedValue = await __privateGet(this, _encryption).encrypt(
|
|
91
|
+
__privateGet(this, _encryptionKey),
|
|
92
|
+
JSON.stringify(newValue)
|
|
93
|
+
);
|
|
94
|
+
__privateGet(this, _sessionStore).set(state.storageKey, storedValue);
|
|
95
|
+
} else {
|
|
96
|
+
__privateGet(this, _sessionStore).delete(state.storageKey);
|
|
142
97
|
}
|
|
143
|
-
(
|
|
144
|
-
const { address, salt, publicKey } = await __privateGet(this, _enokiClient).getZkLogin({ jwt });
|
|
145
|
-
this.$zkLoginState.set({
|
|
146
|
-
...this.$zkLoginState.get(),
|
|
147
|
-
salt,
|
|
148
|
-
address,
|
|
149
|
-
publicKey
|
|
150
|
-
});
|
|
151
|
-
await __privateMethod(this, _INTERNAL_ONLY_EnokiFlow_instances, setSession_fn).call(this, {
|
|
152
|
-
...zkp,
|
|
153
|
-
jwt
|
|
154
|
-
});
|
|
155
|
-
return params.get("state");
|
|
98
|
+
state.$zkLoginSession.set({ initialized: true, value: newValue });
|
|
156
99
|
}
|
|
157
|
-
async getSession() {
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
100
|
+
async getSession({ $zkLoginSession, storageKey }) {
|
|
101
|
+
if ($zkLoginSession.get().initialized) {
|
|
102
|
+
return $zkLoginSession.get().value;
|
|
160
103
|
}
|
|
161
104
|
try {
|
|
162
|
-
const storedValue = __privateGet(this,
|
|
105
|
+
const storedValue = __privateGet(this, _sessionStore).get(storageKey);
|
|
163
106
|
if (!storedValue) return null;
|
|
164
107
|
const state = JSON.parse(
|
|
165
108
|
await __privateGet(this, _encryption).decrypt(__privateGet(this, _encryptionKey), storedValue)
|
|
@@ -167,97 +110,35 @@ class INTERNAL_ONLY_EnokiFlow {
|
|
|
167
110
|
if (state?.expiresAt && Date.now() > state.expiresAt) {
|
|
168
111
|
await this.logout();
|
|
169
112
|
} else {
|
|
170
|
-
|
|
113
|
+
$zkLoginSession.set({ initialized: true, value: state });
|
|
171
114
|
}
|
|
172
115
|
} catch {
|
|
173
|
-
|
|
116
|
+
$zkLoginSession.set({ initialized: true, value: null });
|
|
174
117
|
}
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
async logout() {
|
|
178
|
-
this.$zkLoginState.set({});
|
|
179
|
-
__privateGet(this, _store).delete(__privateGet(this, _storageKeys).STATE);
|
|
180
|
-
await (0, import_idb_keyval.clear)(__privateGet(this, _idbStore));
|
|
181
|
-
await __privateMethod(this, _INTERNAL_ONLY_EnokiFlow_instances, setSession_fn).call(this, null);
|
|
182
|
-
}
|
|
183
|
-
// TODO: Should this return the proof if it already exists?
|
|
184
|
-
async getProof() {
|
|
185
|
-
const zkp = await this.getSession();
|
|
186
|
-
const { salt } = this.$zkLoginState.get();
|
|
187
|
-
if (zkp?.proof) {
|
|
188
|
-
if (zkp.expiresAt && Date.now() > zkp.expiresAt) {
|
|
189
|
-
throw new Error("Stored proof is expired.");
|
|
190
|
-
}
|
|
191
|
-
return zkp.proof;
|
|
192
|
-
}
|
|
193
|
-
if (!salt || !zkp || !zkp.jwt) {
|
|
194
|
-
throw new Error("Missing required parameters for proof generation");
|
|
195
|
-
}
|
|
196
|
-
const storedNativeSigner = await (0, import_idb_keyval.get)(
|
|
197
|
-
"ephemeralKeyPair",
|
|
198
|
-
__privateGet(this, _idbStore)
|
|
199
|
-
);
|
|
200
|
-
if (!storedNativeSigner) {
|
|
201
|
-
throw new Error("Native signer not found in store.");
|
|
202
|
-
}
|
|
203
|
-
const ephemeralKeyPair = import_webcrypto.WebCryptoSigner.import(storedNativeSigner);
|
|
204
|
-
const proof = await __privateGet(this, _enokiClient).createZkLoginZkp({
|
|
205
|
-
network: __privateGet(this, _network),
|
|
206
|
-
jwt: zkp.jwt,
|
|
207
|
-
maxEpoch: zkp.maxEpoch,
|
|
208
|
-
randomness: zkp.randomness,
|
|
209
|
-
ephemeralPublicKey: ephemeralKeyPair.getPublicKey()
|
|
210
|
-
});
|
|
211
|
-
await __privateMethod(this, _INTERNAL_ONLY_EnokiFlow_instances, setSession_fn).call(this, {
|
|
212
|
-
...zkp,
|
|
213
|
-
proof
|
|
214
|
-
});
|
|
215
|
-
return proof;
|
|
216
|
-
}
|
|
217
|
-
async getKeypair() {
|
|
218
|
-
await this.getProof();
|
|
219
|
-
const zkp = await this.getSession();
|
|
220
|
-
const { address } = this.$zkLoginState.get();
|
|
221
|
-
if (!address || !zkp || !zkp.proof) {
|
|
222
|
-
throw new Error("Missing required data for keypair generation.");
|
|
223
|
-
}
|
|
224
|
-
if (Date.now() > zkp.expiresAt) {
|
|
225
|
-
throw new Error("Stored proof is expired.");
|
|
226
|
-
}
|
|
227
|
-
const storedNativeSigner = await (0, import_idb_keyval.get)(
|
|
228
|
-
"ephemeralKeyPair",
|
|
229
|
-
__privateGet(this, _idbStore)
|
|
230
|
-
);
|
|
231
|
-
if (!storedNativeSigner) {
|
|
232
|
-
throw new Error("Native signer not found in store.");
|
|
233
|
-
}
|
|
234
|
-
const ephemeralKeypair = import_webcrypto.WebCryptoSigner.import(storedNativeSigner);
|
|
235
|
-
return new import_EnokiKeypair.EnokiKeypair({
|
|
236
|
-
address,
|
|
237
|
-
ephemeralKeypair,
|
|
238
|
-
maxEpoch: zkp.maxEpoch,
|
|
239
|
-
proof: zkp.proof
|
|
240
|
-
});
|
|
118
|
+
return $zkLoginSession.get().value;
|
|
241
119
|
}
|
|
242
120
|
}
|
|
243
|
-
_storageKeys = new WeakMap();
|
|
244
|
-
_enokiClient = new WeakMap();
|
|
245
|
-
_network = new WeakMap();
|
|
246
121
|
_encryption = new WeakMap();
|
|
247
122
|
_encryptionKey = new WeakMap();
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
123
|
+
_sessionStore = new WeakMap();
|
|
124
|
+
_stateStorageKey = new WeakMap();
|
|
125
|
+
_sessionContextByNetwork = new WeakMap();
|
|
126
|
+
_zkLoginState = new WeakMap();
|
|
127
|
+
_EnokiWalletState_instances = new WeakSet();
|
|
128
|
+
createZkLoginState_fn = function() {
|
|
129
|
+
const storage = (0, import_stores.createLocalStorage)();
|
|
130
|
+
let storedState = null;
|
|
131
|
+
try {
|
|
132
|
+
const rawStoredValue = storage.get(__privateGet(this, _stateStorageKey));
|
|
133
|
+
if (rawStoredValue) {
|
|
134
|
+
storedState = JSON.parse(rawStoredValue);
|
|
135
|
+
}
|
|
136
|
+
} catch {
|
|
260
137
|
}
|
|
261
|
-
|
|
138
|
+
const $zkLoginState = (0, import_nanostores.atom)(storedState || {});
|
|
139
|
+
(0, import_nanostores.onSet)($zkLoginState, ({ newValue }) => {
|
|
140
|
+
storage.set(__privateGet(this, _stateStorageKey), JSON.stringify(newValue));
|
|
141
|
+
});
|
|
142
|
+
return $zkLoginState;
|
|
262
143
|
};
|
|
263
144
|
//# sourceMappingURL=state.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/wallet/state.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { clear, createStore } from 'idb-keyval';\nimport type { WritableAtom } from 'nanostores';\nimport { atom, onMount, onSet } 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_SuiClientTypes } from '@mysten/sui/experimental';\nimport type { SyncStore } from '../stores.js';\nimport { createLocalStorage, createSessionStorage } from '../stores.js';\n\nimport type { EnokiSessionContext, ZkLoginSession, ZkLoginState } from './types.js';\n\nexport type EnokiWalletStateConfig = EnokiClientConfig & {\n\tclients: ClientWithCoreApi[];\n\tclientId: string;\n};\n\nexport class EnokiWalletState {\n\t#encryption: Encryption;\n\t#encryptionKey: string;\n\t#sessionStore: SyncStore;\n\t#stateStorageKey: string;\n\t#sessionContextByNetwork: Map<Experimental_SuiClientTypes.Network, EnokiSessionContext>;\n\t#zkLoginState: WritableAtom<ZkLoginState>;\n\n\tconstructor(config: EnokiWalletStateConfig) {\n\t\tthis.#encryptionKey = config.apiKey;\n\t\tthis.#encryption = createDefaultEncryption();\n\t\tthis.#sessionStore = createSessionStorage();\n\t\tthis.#stateStorageKey = `@enoki/flow/state/${config.apiKey}/${config.clientId}`;\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 storageKey = `@enoki/flow/session/${config.apiKey}/${network}/${config.clientId}`;\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\tstorageKey,\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_SuiClientTypes.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({});\n\t\tthis.#sessionStore.delete(this.#stateStorageKey);\n\n\t\tfor (const state of this.#sessionContextByNetwork.values()) {\n\t\t\tawait clear(state.idbStore);\n\t\t\tawait this.setSession(state, null);\n\t\t}\n\t}\n\n\tasync setSession(state: 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\tthis.#sessionStore.set(state.storageKey, storedValue);\n\t\t} else {\n\t\t\tthis.#sessionStore.delete(state.storageKey);\n\t\t}\n\n\t\tstate.$zkLoginSession.set({ initialized: true, value: newValue });\n\t}\n\n\tasync getSession({ $zkLoginSession, storageKey }: 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 = this.#sessionStore.get(storageKey);\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 storage = createLocalStorage();\n\t\tlet storedState: ZkLoginState | null = null;\n\n\t\ttry {\n\t\t\tconst rawStoredValue = storage.get(this.#stateStorageKey);\n\t\t\tif (rawStoredValue) {\n\t\t\t\tstoredState = JSON.parse(rawStoredValue);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors\n\t\t}\n\n\t\tconst $zkLoginState = atom<ZkLoginState>(storedState || {});\n\n\t\tonSet($zkLoginState, ({ newValue }) => {\n\t\t\tstorage.set(this.#stateStorageKey, JSON.stringify(newValue));\n\t\t});\n\n\t\treturn $zkLoginState;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,28 +1,72 @@
|
|
|
1
1
|
import type { SuiClient } from '@mysten/sui/client';
|
|
2
|
-
import type { StandardEventsListeners } from '@mysten/wallet-standard';
|
|
2
|
+
import type { StandardEventsListeners, Wallet } from '@mysten/wallet-standard';
|
|
3
3
|
import type { EnokiClientConfig } from '../EnokiClient/index.js';
|
|
4
4
|
import type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';
|
|
5
|
+
import type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';
|
|
6
|
+
import type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';
|
|
7
|
+
import type { UseStore } from 'idb-keyval';
|
|
8
|
+
import type { WritableAtom } from 'nanostores';
|
|
5
9
|
export type WalletEventsMap = {
|
|
6
10
|
[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];
|
|
7
11
|
};
|
|
8
|
-
export
|
|
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
|
+
storageKey: string;
|
|
27
|
+
$zkLoginSession: WritableAtom<{
|
|
28
|
+
initialized: boolean;
|
|
29
|
+
value: ZkLoginSession | null;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
export type EnokiWalletOptions = {
|
|
33
|
+
provider: AuthProvider;
|
|
34
|
+
windowFeatures?: string | (() => string);
|
|
35
|
+
clients: ClientWithCoreApi[];
|
|
36
|
+
getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
|
|
37
|
+
} & AuthProviderOptions & EnokiClientConfig & Pick<Wallet, 'name' | 'icon'>;
|
|
38
|
+
export type AuthProviderOptions = {
|
|
39
|
+
/**
|
|
40
|
+
* The OAuth client ID.
|
|
41
|
+
*/
|
|
42
|
+
clientId: string;
|
|
43
|
+
/**
|
|
44
|
+
* The URL to redirect to after authorization.
|
|
45
|
+
*/
|
|
46
|
+
redirectUrl?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Extra parameters to include in the authorization URL.
|
|
49
|
+
*/
|
|
50
|
+
extraParams?: Record<string, string>;
|
|
51
|
+
};
|
|
52
|
+
export type RegisterEnokiWalletsOptions = EnokiClientConfig & {
|
|
9
53
|
/**
|
|
10
54
|
* Configuration for each OAuth provider.
|
|
11
55
|
*/
|
|
12
|
-
providers: Partial<Record<AuthProvider,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
56
|
+
providers: Partial<Record<AuthProvider, AuthProviderOptions>>;
|
|
57
|
+
/**
|
|
58
|
+
* The window features to use when opening the authorization popup.
|
|
59
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures
|
|
60
|
+
*/
|
|
61
|
+
windowFeatures?: string | (() => string);
|
|
62
|
+
} & ({
|
|
63
|
+
/**
|
|
64
|
+
* A list of client instances to use when building and executing transactions.
|
|
65
|
+
*/
|
|
66
|
+
clients: ClientWithCoreApi[];
|
|
67
|
+
/** A function that returns the current network that the application is acting on. */
|
|
68
|
+
getCurrentNetwork: () => Experimental_SuiClientTypes.Network;
|
|
69
|
+
} | {
|
|
26
70
|
/**
|
|
27
71
|
* The SuiClient instance to use when building and executing transactions.
|
|
28
72
|
*/
|
|
@@ -32,9 +76,4 @@ export interface RegisterEnokiWalletsOptions extends EnokiClientConfig {
|
|
|
32
76
|
* @default 'mainnet'
|
|
33
77
|
*/
|
|
34
78
|
network?: EnokiNetwork;
|
|
35
|
-
|
|
36
|
-
* The window features to use when opening the authorization popup.
|
|
37
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures
|
|
38
|
-
*/
|
|
39
|
-
windowFeatures?: string | (() => string);
|
|
40
|
-
}
|
|
79
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/wallet/types.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { StandardEventsListeners } from '@mysten/wallet-standard';\n\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\n\nexport type WalletEventsMap = {\n\t[E in keyof StandardEventsListeners]: Parameters<StandardEventsListeners[E]>[0];\n};\n\nexport
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { StandardEventsListeners, Wallet } from '@mysten/wallet-standard';\n\nimport type { EnokiClientConfig } from '../EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from '../EnokiClient/type.js';\nimport type { ClientWithCoreApi, Experimental_SuiClientTypes } from '@mysten/sui/experimental';\nimport type { ZkLoginSignatureInputs } from '@mysten/sui/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\tstorageKey: string;\n\t$zkLoginSession: WritableAtom<{ initialized: boolean; value: ZkLoginSession | null }>;\n};\n\nexport type EnokiWalletOptions = {\n\tprovider: AuthProvider;\n\twindowFeatures?: string | (() => string);\n\tclients: ClientWithCoreApi[];\n\tgetCurrentNetwork: () => Experimental_SuiClientTypes.Network;\n} & AuthProviderOptions &\n\tEnokiClientConfig &\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>;\n};\n\nexport type RegisterEnokiWalletsOptions = EnokiClientConfig & {\n\t/**\n\t * Configuration for each OAuth provider.\n\t */\n\tproviders: Partial<Record<AuthProvider, AuthProviderOptions>>;\n\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\t| {\n\t\t\t\t/**\n\t\t\t\t * A list of client instances to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclients: ClientWithCoreApi[];\n\n\t\t\t\t/** A function that returns the current network that the application is acting on. */\n\t\t\t\tgetCurrentNetwork: () => Experimental_SuiClientTypes.Network;\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * The SuiClient instance to use when building and executing transactions.\n\t\t\t\t */\n\t\t\t\tclient: SuiClient;\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
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Wallet } from '@mysten/wallet-standard';
|
|
2
2
|
import type { UiWallet } from '@wallet-standard/ui';
|
|
3
|
-
import type { EnokiWallet } from './
|
|
3
|
+
import type { EnokiWallet } from './wallet.js';
|
|
4
4
|
export declare function isEnokiWallet(wallet: UiWallet): boolean;
|
|
5
5
|
export declare function isEnokiWallet(wallet: Wallet): wallet is EnokiWallet;
|
|
6
6
|
export declare function getWalletMetadata(wallet: Wallet | UiWallet): import("./feature.js").EnokiGetMetadataOutput | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 '@mysten/wallet-standard';\nimport type { UiWallet } from '@wallet-standard/ui';\nimport { getWalletFeature } from '@wallet-standard/ui';\nimport type { EnokiWallet } from './
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet, WalletWithFeatures } from '@mysten/wallet-standard';\nimport type { UiWallet } from '@wallet-standard/ui';\nimport { getWalletFeature } from '@wallet-standard/ui';\nimport type { EnokiWallet } from './wallet.js';\nimport type { EnokiGetMetadataFeature } from './feature.js';\nimport { EnokiGetMetadata } from './feature.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 (error) {\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 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
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,gBAAiC;AAGjC,qBAAiC;AAI1B,SAAS,cAAc,QAA2B;AACxD,MAAI,eAAe,MAAM,GAAG;AAC3B,WAAO,OAAO,SAAS,SAAS,+BAAgB;AAAA,EACjD;AACA,SAAO,mCAAoB,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,SAAS,OAAO;AACf,aAAO;AAAA,IACR;AAAA,EACD,WAAW,mCAAoB,OAAO,UAAU;AAC/C,UAAM,oBAAoB;AAC1B,WAAO,kBAAkB,SAAS,+BAAgB,EAAE,YAAY;AAAA,EACjE;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
import type { SuiClient } from '@mysten/sui/client';
|
|
2
1
|
import type { StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, SuiSignAndExecuteTransactionFeature, SuiSignPersonalMessageFeature, SuiSignTransactionFeature, Wallet } from '@mysten/wallet-standard';
|
|
3
2
|
import { ReadonlyWalletAccount } from '@mysten/wallet-standard';
|
|
4
3
|
import type { AuthProvider } from '../EnokiClient/type.js';
|
|
5
|
-
import {
|
|
6
|
-
import type { RegisterEnokiWalletsOptions } from './types.js';
|
|
4
|
+
import type { EnokiWalletOptions } from './types.js';
|
|
7
5
|
import type { EnokiGetMetadataFeature } from './feature.js';
|
|
8
6
|
export declare class EnokiWallet implements Wallet {
|
|
9
7
|
#private;
|
|
10
|
-
get id(): string;
|
|
11
8
|
get name(): string;
|
|
12
9
|
get provider(): AuthProvider;
|
|
13
10
|
get icon(): `data:image/svg+xml;base64,${string}` | `data:image/webp;base64,${string}` | `data:image/png;base64,${string}` | `data:image/gif;base64,${string}`;
|
|
14
11
|
get version(): "1.0.0";
|
|
15
|
-
get chains():
|
|
12
|
+
get chains(): `sui:${string & {}}`[];
|
|
16
13
|
get accounts(): ReadonlyWalletAccount[];
|
|
17
14
|
get features(): StandardConnectFeature & StandardDisconnectFeature & StandardEventsFeature & SuiSignTransactionFeature & SuiSignAndExecuteTransactionFeature & SuiSignPersonalMessageFeature & EnokiGetMetadataFeature;
|
|
18
|
-
constructor({ name, icon,
|
|
19
|
-
icon: Wallet['icon'];
|
|
20
|
-
name: string;
|
|
21
|
-
flow: INTERNAL_ONLY_EnokiFlow;
|
|
22
|
-
provider: AuthProvider;
|
|
23
|
-
clientId: string;
|
|
24
|
-
redirectUrl?: string;
|
|
25
|
-
extraParams?: Record<string, string>;
|
|
26
|
-
client: SuiClient;
|
|
27
|
-
windowFeatures?: string | (() => string);
|
|
28
|
-
});
|
|
15
|
+
constructor({ name, icon, provider, clientId, redirectUrl, extraParams, windowFeatures, getCurrentNetwork, apiKey, apiUrl, clients, }: EnokiWalletOptions);
|
|
29
16
|
}
|
|
30
|
-
export declare function registerEnokiWallets({ providers, client, network, windowFeatures, ...config }: RegisterEnokiWalletsOptions): {
|
|
31
|
-
wallets: Partial<Record<AuthProvider, EnokiWallet>>;
|
|
32
|
-
unregister: () => void;
|
|
33
|
-
};
|
|
34
|
-
export declare function defaultWindowFeatures(): string;
|