@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.
Files changed (110) hide show
  1. package/CHANGELOG.md +1109 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/EnokiClient/index.d.ts +36 -0
  4. package/dist/cjs/EnokiClient/index.js +196 -0
  5. package/dist/cjs/EnokiClient/index.js.map +7 -0
  6. package/dist/cjs/EnokiClient/type.d.ts +119 -0
  7. package/dist/cjs/EnokiClient/type.js +17 -0
  8. package/dist/cjs/EnokiClient/type.js.map +7 -0
  9. package/dist/cjs/EnokiFlow.d.ts +74 -0
  10. package/dist/cjs/EnokiFlow.js +279 -0
  11. package/dist/cjs/EnokiFlow.js.map +7 -0
  12. package/dist/cjs/EnokiKeypair.d.ts +20 -0
  13. package/dist/cjs/EnokiKeypair.js +87 -0
  14. package/dist/cjs/EnokiKeypair.js.map +7 -0
  15. package/dist/cjs/encryption.d.ts +15 -0
  16. package/dist/cjs/encryption.js +96 -0
  17. package/dist/cjs/encryption.js.map +7 -0
  18. package/dist/cjs/index.d.ts +12 -0
  19. package/dist/cjs/index.js +50 -0
  20. package/dist/cjs/index.js.map +7 -0
  21. package/dist/cjs/package.json +4 -0
  22. package/dist/cjs/react.d.ts +20 -0
  23. package/dist/cjs/react.js +76 -0
  24. package/dist/cjs/react.js.map +7 -0
  25. package/dist/cjs/stores.d.ts +21 -0
  26. package/dist/cjs/stores.js +67 -0
  27. package/dist/cjs/stores.js.map +7 -0
  28. package/dist/cjs/utils.d.ts +2 -0
  29. package/dist/cjs/utils.js +27 -0
  30. package/dist/cjs/utils.js.map +7 -0
  31. package/dist/cjs/wallet/features.d.ts +50 -0
  32. package/dist/cjs/wallet/features.js +27 -0
  33. package/dist/cjs/wallet/features.js.map +7 -0
  34. package/dist/cjs/wallet/initializer.d.ts +11 -0
  35. package/dist/cjs/wallet/initializer.js +41 -0
  36. package/dist/cjs/wallet/initializer.js.map +7 -0
  37. package/dist/cjs/wallet/providers.d.ts +7 -0
  38. package/dist/cjs/wallet/providers.js +51 -0
  39. package/dist/cjs/wallet/providers.js.map +7 -0
  40. package/dist/cjs/wallet/register.d.ts +7 -0
  41. package/dist/cjs/wallet/register.js +68 -0
  42. package/dist/cjs/wallet/register.js.map +7 -0
  43. package/dist/cjs/wallet/state.d.ts +18 -0
  44. package/dist/cjs/wallet/state.js +142 -0
  45. package/dist/cjs/wallet/state.js.map +7 -0
  46. package/dist/cjs/wallet/types.d.ts +82 -0
  47. package/dist/cjs/wallet/types.js +17 -0
  48. package/dist/cjs/wallet/types.js.map +7 -0
  49. package/dist/cjs/wallet/utils.d.ts +11 -0
  50. package/dist/cjs/wallet/utils.js +83 -0
  51. package/dist/cjs/wallet/utils.js.map +7 -0
  52. package/dist/cjs/wallet/wallet.d.ts +16 -0
  53. package/dist/cjs/wallet/wallet.js +466 -0
  54. package/dist/cjs/wallet/wallet.js.map +7 -0
  55. package/dist/esm/EnokiClient/index.d.ts +36 -0
  56. package/dist/esm/EnokiClient/index.js +176 -0
  57. package/dist/esm/EnokiClient/index.js.map +7 -0
  58. package/dist/esm/EnokiClient/type.d.ts +119 -0
  59. package/dist/esm/EnokiClient/type.js +1 -0
  60. package/dist/esm/EnokiClient/type.js.map +7 -0
  61. package/dist/esm/EnokiFlow.d.ts +74 -0
  62. package/dist/esm/EnokiFlow.js +259 -0
  63. package/dist/esm/EnokiFlow.js.map +7 -0
  64. package/dist/esm/EnokiKeypair.d.ts +20 -0
  65. package/dist/esm/EnokiKeypair.js +67 -0
  66. package/dist/esm/EnokiKeypair.js.map +7 -0
  67. package/dist/esm/encryption.d.ts +15 -0
  68. package/dist/esm/encryption.js +76 -0
  69. package/dist/esm/encryption.js.map +7 -0
  70. package/dist/esm/index.d.ts +12 -0
  71. package/dist/esm/index.js +41 -0
  72. package/dist/esm/index.js.map +7 -0
  73. package/dist/esm/package.json +4 -0
  74. package/dist/esm/react.d.ts +20 -0
  75. package/dist/esm/react.js +56 -0
  76. package/dist/esm/react.js.map +7 -0
  77. package/dist/esm/stores.d.ts +21 -0
  78. package/dist/esm/stores.js +47 -0
  79. package/dist/esm/stores.js.map +7 -0
  80. package/dist/esm/utils.d.ts +2 -0
  81. package/dist/esm/utils.js +7 -0
  82. package/dist/esm/utils.js.map +7 -0
  83. package/dist/esm/wallet/features.d.ts +50 -0
  84. package/dist/esm/wallet/features.js +7 -0
  85. package/dist/esm/wallet/features.js.map +7 -0
  86. package/dist/esm/wallet/initializer.d.ts +11 -0
  87. package/dist/esm/wallet/initializer.js +21 -0
  88. package/dist/esm/wallet/initializer.js.map +7 -0
  89. package/dist/esm/wallet/providers.d.ts +7 -0
  90. package/dist/esm/wallet/providers.js +31 -0
  91. package/dist/esm/wallet/providers.js.map +7 -0
  92. package/dist/esm/wallet/register.d.ts +7 -0
  93. package/dist/esm/wallet/register.js +48 -0
  94. package/dist/esm/wallet/register.js.map +7 -0
  95. package/dist/esm/wallet/state.d.ts +18 -0
  96. package/dist/esm/wallet/state.js +122 -0
  97. package/dist/esm/wallet/state.js.map +7 -0
  98. package/dist/esm/wallet/types.d.ts +82 -0
  99. package/dist/esm/wallet/types.js +1 -0
  100. package/dist/esm/wallet/types.js.map +7 -0
  101. package/dist/esm/wallet/utils.d.ts +11 -0
  102. package/dist/esm/wallet/utils.js +63 -0
  103. package/dist/esm/wallet/utils.js.map +7 -0
  104. package/dist/esm/wallet/wallet.d.ts +16 -0
  105. package/dist/esm/wallet/wallet.js +444 -0
  106. package/dist/esm/wallet/wallet.js.map +7 -0
  107. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  108. package/dist/tsconfig.tsbuildinfo +1 -0
  109. package/package.json +80 -0
  110. package/react/package.json +5 -0
@@ -0,0 +1,279 @@
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 EnokiFlow_exports = {};
28
+ __export(EnokiFlow_exports, {
29
+ EnokiFlow: () => EnokiFlow
30
+ });
31
+ module.exports = __toCommonJS(EnokiFlow_exports);
32
+ var import_webcrypto = require("@haneullabs/signers/webcrypto");
33
+ var import_cryptography = require("@haneullabs/haneul/cryptography");
34
+ var import_ed25519 = require("@haneullabs/haneul/keypairs/ed25519");
35
+ var import_utils = require("@haneullabs/haneul/utils");
36
+ var import_zklogin = require("@haneullabs/haneul/zklogin");
37
+ var import_idb_keyval = require("idb-keyval");
38
+ var import_nanostores = require("nanostores");
39
+ var import_encryption = require("./encryption.js");
40
+ var import_EnokiClient = require("./EnokiClient/index.js");
41
+ var import_EnokiKeypair = require("./EnokiKeypair.js");
42
+ var import_stores = require("./stores.js");
43
+ var _storageKeys, _enokiClient, _encryption, _encryptionKey, _store, _useNativeCryptoSigner, _idbStore, _EnokiFlow_instances, setSession_fn;
44
+ const createStorageKeys = (apiKey) => ({
45
+ STATE: `@enoki/flow/state/${apiKey}`,
46
+ SESSION: `@enoki/flow/session/${apiKey}`
47
+ });
48
+ class EnokiFlow {
49
+ constructor(config) {
50
+ __privateAdd(this, _EnokiFlow_instances);
51
+ __privateAdd(this, _storageKeys);
52
+ __privateAdd(this, _enokiClient);
53
+ __privateAdd(this, _encryption);
54
+ __privateAdd(this, _encryptionKey);
55
+ __privateAdd(this, _store);
56
+ __privateAdd(this, _useNativeCryptoSigner);
57
+ __privateAdd(this, _idbStore);
58
+ __privateSet(this, _enokiClient, new import_EnokiClient.EnokiClient({
59
+ apiKey: config.apiKey,
60
+ apiUrl: config.apiUrl,
61
+ additionalEpochs: config.additionalEpochs
62
+ }));
63
+ __privateSet(this, _encryptionKey, config.apiKey);
64
+ if (config.experimental_nativeCryptoSigner) {
65
+ __privateSet(this, _useNativeCryptoSigner, true);
66
+ __privateSet(this, _idbStore, (0, import_idb_keyval.createStore)(config.apiKey, "enoki"));
67
+ } else {
68
+ __privateSet(this, _useNativeCryptoSigner, false);
69
+ }
70
+ __privateSet(this, _encryption, config.encryption ?? (0, import_encryption.createDefaultEncryption)());
71
+ __privateSet(this, _store, config.store ?? (0, import_stores.createSessionStorage)());
72
+ __privateSet(this, _storageKeys, createStorageKeys(config.apiKey));
73
+ let storedState = null;
74
+ try {
75
+ const rawStoredValue = __privateGet(this, _store).get(__privateGet(this, _storageKeys).STATE);
76
+ if (rawStoredValue) {
77
+ storedState = JSON.parse(rawStoredValue);
78
+ }
79
+ } catch {
80
+ }
81
+ this.$zkLoginState = (0, import_nanostores.atom)(storedState || {});
82
+ this.$zkLoginSession = (0, import_nanostores.atom)({ initialized: false, value: null });
83
+ (0, import_nanostores.onMount)(this.$zkLoginSession, () => {
84
+ this.getSession();
85
+ });
86
+ (0, import_nanostores.onSet)(this.$zkLoginState, ({ newValue }) => {
87
+ __privateGet(this, _store).set(__privateGet(this, _storageKeys).STATE, JSON.stringify(newValue));
88
+ });
89
+ }
90
+ get enokiClient() {
91
+ return __privateGet(this, _enokiClient);
92
+ }
93
+ async createAuthorizationURL(input) {
94
+ const ephemeralKeyPair = __privateGet(this, _useNativeCryptoSigner) ? await import_webcrypto.WebCryptoSigner.generate() : new import_ed25519.Ed25519Keypair();
95
+ const { nonce, randomness, maxEpoch, estimatedExpiration } = await __privateGet(this, _enokiClient).createZkLoginNonce({
96
+ network: input.network,
97
+ ephemeralPublicKey: ephemeralKeyPair.getPublicKey()
98
+ });
99
+ const params = new URLSearchParams({
100
+ ...input.extraParams,
101
+ nonce,
102
+ client_id: input.clientId,
103
+ redirect_uri: input.redirectUrl,
104
+ response_type: "id_token",
105
+ // TODO: Eventually fetch the scopes for this client ID from the Enoki service:
106
+ scope: [
107
+ "openid",
108
+ // Merge the requested scopes in with the required openid scopes:
109
+ ...input.extraParams && "scope" in input.extraParams ? input.extraParams.scope : []
110
+ ].filter(Boolean).join(" ")
111
+ });
112
+ let oauthUrl;
113
+ switch (input.provider) {
114
+ case "google": {
115
+ oauthUrl = `https://accounts.google.com/o/oauth2/v2/auth?${params}`;
116
+ break;
117
+ }
118
+ case "facebook": {
119
+ oauthUrl = `https://www.facebook.com/v17.0/dialog/oauth?${params}`;
120
+ break;
121
+ }
122
+ case "twitch": {
123
+ params.set("force_verify", "true");
124
+ oauthUrl = `https://id.twitch.tv/oauth2/authorize?${params}`;
125
+ break;
126
+ }
127
+ default:
128
+ throw new Error(`Invalid provider: ${input.provider}`);
129
+ }
130
+ this.$zkLoginState.set({ provider: input.provider });
131
+ if (__privateGet(this, _useNativeCryptoSigner)) {
132
+ await (0, import_idb_keyval.set)("ephemeralKeyPair", ephemeralKeyPair.export(), __privateGet(this, _idbStore));
133
+ }
134
+ await __privateMethod(this, _EnokiFlow_instances, setSession_fn).call(this, {
135
+ expiresAt: estimatedExpiration,
136
+ maxEpoch,
137
+ randomness,
138
+ ephemeralKeyPair: __privateGet(this, _useNativeCryptoSigner) ? "@@native" : (0, import_utils.toBase64)(
139
+ (0, import_cryptography.decodeHaneulPrivateKey)(ephemeralKeyPair.getSecretKey()).secretKey
140
+ )
141
+ });
142
+ return oauthUrl;
143
+ }
144
+ // TODO: Should our SDK manage this automatically in addition to exposing a method?
145
+ async handleAuthCallback(hash = window.location.hash) {
146
+ const params = new URLSearchParams(hash.startsWith("#") ? hash.slice(1) : hash);
147
+ const zkp = await this.getSession();
148
+ if (!zkp || !zkp.ephemeralKeyPair || !zkp.maxEpoch || !zkp.randomness) {
149
+ throw new Error(
150
+ "Start of sign-in flow could not be found. Ensure you have started the sign-in flow before calling this."
151
+ );
152
+ }
153
+ const jwt = params.get("id_token");
154
+ if (!jwt) {
155
+ throw new Error("Missing ID Token");
156
+ }
157
+ (0, import_zklogin.decodeJwt)(jwt);
158
+ const { address, salt, publicKey } = await __privateGet(this, _enokiClient).getZkLogin({ jwt });
159
+ this.$zkLoginState.set({
160
+ ...this.$zkLoginState.get(),
161
+ salt,
162
+ address,
163
+ publicKey
164
+ });
165
+ await __privateMethod(this, _EnokiFlow_instances, setSession_fn).call(this, {
166
+ ...zkp,
167
+ jwt
168
+ });
169
+ return params.get("state");
170
+ }
171
+ async getSession() {
172
+ if (this.$zkLoginSession.get().initialized) {
173
+ return this.$zkLoginSession.get().value;
174
+ }
175
+ try {
176
+ const storedValue = __privateGet(this, _store).get(__privateGet(this, _storageKeys).SESSION);
177
+ if (!storedValue) return null;
178
+ const state = JSON.parse(
179
+ await __privateGet(this, _encryption).decrypt(__privateGet(this, _encryptionKey), storedValue)
180
+ );
181
+ if (state?.expiresAt && Date.now() > state.expiresAt) {
182
+ await this.logout();
183
+ } else {
184
+ this.$zkLoginSession.set({ initialized: true, value: state });
185
+ }
186
+ } catch {
187
+ this.$zkLoginSession.set({ initialized: true, value: null });
188
+ }
189
+ return this.$zkLoginSession.get().value;
190
+ }
191
+ async logout() {
192
+ this.$zkLoginState.set({});
193
+ __privateGet(this, _store).delete(__privateGet(this, _storageKeys).STATE);
194
+ if (__privateGet(this, _useNativeCryptoSigner)) {
195
+ await (0, import_idb_keyval.clear)(__privateGet(this, _idbStore));
196
+ }
197
+ await __privateMethod(this, _EnokiFlow_instances, setSession_fn).call(this, null);
198
+ }
199
+ // TODO: Should this return the proof if it already exists?
200
+ async getProof({ network } = {}) {
201
+ const zkp = await this.getSession();
202
+ const { salt } = this.$zkLoginState.get();
203
+ if (zkp?.proof) {
204
+ if (zkp.expiresAt && Date.now() > zkp.expiresAt) {
205
+ throw new Error("Stored proof is expired.");
206
+ }
207
+ return zkp.proof;
208
+ }
209
+ if (!salt || !zkp || !zkp.jwt) {
210
+ throw new Error("Missing required parameters for proof generation");
211
+ }
212
+ let storedNativeSigner = void 0;
213
+ if (__privateGet(this, _useNativeCryptoSigner) && zkp.ephemeralKeyPair === "@@native") {
214
+ storedNativeSigner = await (0, import_idb_keyval.get)("ephemeralKeyPair", __privateGet(this, _idbStore));
215
+ if (!storedNativeSigner) {
216
+ throw new Error("Native signer not found in store.");
217
+ }
218
+ }
219
+ const ephemeralKeyPair = zkp.ephemeralKeyPair === "@@native" ? import_webcrypto.WebCryptoSigner.import(storedNativeSigner) : import_ed25519.Ed25519Keypair.fromSecretKey((0, import_utils.fromBase64)(zkp.ephemeralKeyPair));
220
+ const proof = await __privateGet(this, _enokiClient).createZkLoginZkp({
221
+ network,
222
+ jwt: zkp.jwt,
223
+ maxEpoch: zkp.maxEpoch,
224
+ randomness: zkp.randomness,
225
+ ephemeralPublicKey: ephemeralKeyPair.getPublicKey()
226
+ });
227
+ await __privateMethod(this, _EnokiFlow_instances, setSession_fn).call(this, {
228
+ ...zkp,
229
+ proof
230
+ });
231
+ return proof;
232
+ }
233
+ async getKeypair({ network } = {}) {
234
+ await this.getProof({ network });
235
+ const zkp = await this.getSession();
236
+ const { address } = this.$zkLoginState.get();
237
+ if (!address || !zkp || !zkp.proof) {
238
+ throw new Error("Missing required data for keypair generation.");
239
+ }
240
+ if (Date.now() > zkp.expiresAt) {
241
+ throw new Error("Stored proof is expired.");
242
+ }
243
+ let storedNativeSigner = void 0;
244
+ if (__privateGet(this, _useNativeCryptoSigner) && zkp.ephemeralKeyPair === "@@native") {
245
+ storedNativeSigner = await (0, import_idb_keyval.get)("ephemeralKeyPair", __privateGet(this, _idbStore));
246
+ if (!storedNativeSigner) {
247
+ throw new Error("Native signer not found in store.");
248
+ }
249
+ }
250
+ const ephemeralKeypair = zkp.ephemeralKeyPair === "@@native" ? import_webcrypto.WebCryptoSigner.import(storedNativeSigner) : import_ed25519.Ed25519Keypair.fromSecretKey((0, import_utils.fromBase64)(zkp.ephemeralKeyPair));
251
+ return new import_EnokiKeypair.EnokiKeypair({
252
+ address,
253
+ ephemeralKeypair,
254
+ maxEpoch: zkp.maxEpoch,
255
+ proof: zkp.proof
256
+ });
257
+ }
258
+ }
259
+ _storageKeys = new WeakMap();
260
+ _enokiClient = new WeakMap();
261
+ _encryption = new WeakMap();
262
+ _encryptionKey = new WeakMap();
263
+ _store = new WeakMap();
264
+ _useNativeCryptoSigner = new WeakMap();
265
+ _idbStore = new WeakMap();
266
+ _EnokiFlow_instances = new WeakSet();
267
+ setSession_fn = async function(newValue) {
268
+ if (newValue) {
269
+ const storedValue = await __privateGet(this, _encryption).encrypt(
270
+ __privateGet(this, _encryptionKey),
271
+ JSON.stringify(newValue)
272
+ );
273
+ __privateGet(this, _store).set(__privateGet(this, _storageKeys).SESSION, storedValue);
274
+ } else {
275
+ __privateGet(this, _store).delete(__privateGet(this, _storageKeys).SESSION);
276
+ }
277
+ this.$zkLoginSession.set({ initialized: true, value: newValue });
278
+ };
279
+ //# sourceMappingURL=EnokiFlow.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/EnokiFlow.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ExportedWebCryptoKeypair } from '@haneullabs/signers/webcrypto';\nimport { WebCryptoSigner } from '@haneullabs/signers/webcrypto';\nimport { decodeHaneulPrivateKey } from '@haneullabs/haneul/cryptography';\nimport { Ed25519Keypair } from '@haneullabs/haneul/keypairs/ed25519';\nimport { fromBase64, toBase64 } from '@haneullabs/haneul/utils';\nimport { decodeJwt } from '@haneullabs/haneul/zklogin';\nimport type { ZkLoginSignatureInputs } from '@haneullabs/haneul/zklogin';\nimport type { UseStore } from 'idb-keyval';\nimport { clear, createStore, get, set } 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 { EnokiClient } from './EnokiClient/index.js';\nimport type { AuthProvider, EnokiNetwork } from './EnokiClient/type.js';\nimport { EnokiKeypair } from './EnokiKeypair.js';\nimport type { SyncStore } from './stores.js';\nimport { createSessionStorage } from './stores.js';\n\n/**\n * @deprecated Use `RegisterEnokiWalletsOptions` instead\n */\nexport type EnokiFlowConfig = EnokiClientConfig &\n\t(\n\t\t| {\n\t\t\t\texperimental_nativeCryptoSigner?: unknown;\n\t\t\t\t/**\n\t\t\t\t * The storage interface to persist Enoki data locally.\n\t\t\t\t * If not provided, it will use a sessionStorage-backed store.\n\t\t\t\t */\n\t\t\t\tstore?: SyncStore;\n\t\t\t\t/**\n\t\t\t\t * The encryption interface that will be used to encrypt data before storing it locally.\n\t\t\t\t * If not provided, it will use a default encryption interface.\n\t\t\t\t */\n\t\t\t\tencryption?: Encryption;\n\t\t }\n\t\t| {\n\t\t\t\tstore?: never;\n\t\t\t\tencryption?: never;\n\t\t\t\t/**\n\t\t\t\t * Enables the new native crypto signer for the EnokiFlow, which is more secure.\n\t\t\t\t */\n\t\t\t\texperimental_nativeCryptoSigner: true;\n\t\t }\n\t);\n\n// State that is not bound to a session, and is encrypted.\nexport interface ZkLoginState {\n\tprovider?: AuthProvider;\n\taddress?: string;\n\tsalt?: string;\n\tpublicKey?: string;\n}\n\n// State that session-bound, and is encrypted in storage.\nexport interface ZkLoginSession {\n\tephemeralKeyPair: string;\n\tmaxEpoch: number;\n\trandomness: string;\n\texpiresAt: number;\n\n\tjwt?: string;\n\tproof?: ZkLoginSignatureInputs;\n}\n\nconst createStorageKeys = (apiKey: string) => ({\n\tSTATE: `@enoki/flow/state/${apiKey}`,\n\tSESSION: `@enoki/flow/session/${apiKey}`,\n});\n\n/**\n * @deprecated Use `registerEnokiWallets` instead\n */\nexport class EnokiFlow {\n\t#storageKeys: { STATE: string; SESSION: string };\n\t#enokiClient: EnokiClient;\n\t#encryption: Encryption;\n\t#encryptionKey: string;\n\t#store: SyncStore;\n\t#useNativeCryptoSigner: boolean;\n\t#idbStore?: UseStore;\n\n\t$zkLoginSession: WritableAtom<{ initialized: boolean; value: ZkLoginSession | null }>;\n\t$zkLoginState: WritableAtom<ZkLoginState>;\n\n\tconstructor(config: EnokiFlowConfig) {\n\t\tthis.#enokiClient = new EnokiClient({\n\t\t\tapiKey: config.apiKey,\n\t\t\tapiUrl: config.apiUrl,\n\t\t\tadditionalEpochs: config.additionalEpochs,\n\t\t});\n\t\tthis.#encryptionKey = config.apiKey;\n\n\t\tif (config.experimental_nativeCryptoSigner) {\n\t\t\tthis.#useNativeCryptoSigner = true;\n\t\t\tthis.#idbStore = createStore(config.apiKey, 'enoki');\n\t\t} else {\n\t\t\tthis.#useNativeCryptoSigner = false;\n\t\t}\n\n\t\tthis.#encryption = config.encryption ?? createDefaultEncryption();\n\t\tthis.#store = config.store ?? createSessionStorage();\n\t\tthis.#storageKeys = createStorageKeys(config.apiKey);\n\n\t\tlet storedState = null;\n\t\ttry {\n\t\t\tconst rawStoredValue = this.#store.get(this.#storageKeys.STATE);\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\tthis.$zkLoginState = atom(storedState || {});\n\t\tthis.$zkLoginSession = atom({ initialized: false, value: null });\n\n\t\t// Hydrate the session on mount:\n\t\tonMount(this.$zkLoginSession, () => {\n\t\t\tthis.getSession();\n\t\t});\n\n\t\tonSet(this.$zkLoginState, ({ newValue }) => {\n\t\t\tthis.#store.set(this.#storageKeys.STATE, JSON.stringify(newValue));\n\t\t});\n\t}\n\n\tget enokiClient() {\n\t\treturn this.#enokiClient;\n\t}\n\n\tasync createAuthorizationURL(input: {\n\t\tprovider: AuthProvider;\n\t\tclientId: string;\n\t\tredirectUrl: string;\n\t\tnetwork?: 'mainnet' | 'testnet' | 'devnet';\n\t\textraParams?: Record<string, unknown>;\n\t}) {\n\t\tconst ephemeralKeyPair = this.#useNativeCryptoSigner\n\t\t\t? await WebCryptoSigner.generate()\n\t\t\t: new Ed25519Keypair();\n\n\t\tconst { nonce, randomness, maxEpoch, estimatedExpiration } =\n\t\t\tawait this.#enokiClient.createZkLoginNonce({\n\t\t\t\tnetwork: input.network,\n\t\t\t\tephemeralPublicKey: ephemeralKeyPair.getPublicKey(),\n\t\t\t});\n\n\t\tconst params = new URLSearchParams({\n\t\t\t...input.extraParams,\n\t\t\tnonce,\n\t\t\tclient_id: input.clientId,\n\t\t\tredirect_uri: input.redirectUrl,\n\t\t\tresponse_type: 'id_token',\n\t\t\t// TODO: Eventually fetch the scopes for this client ID from the Enoki service:\n\t\t\tscope: [\n\t\t\t\t'openid',\n\t\t\t\t// Merge the requested scopes in with the required openid scopes:\n\t\t\t\t...(input.extraParams && 'scope' in input.extraParams\n\t\t\t\t\t? (input.extraParams.scope as string[])\n\t\t\t\t\t: []),\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' '),\n\t\t});\n\n\t\tlet oauthUrl: string;\n\t\tswitch (input.provider) {\n\t\t\tcase 'google': {\n\t\t\t\toauthUrl = `https://accounts.google.com/o/oauth2/v2/auth?${params}`;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'facebook': {\n\t\t\t\toauthUrl = `https://www.facebook.com/v17.0/dialog/oauth?${params}`;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'twitch': {\n\t\t\t\tparams.set('force_verify', 'true');\n\t\t\t\toauthUrl = `https://id.twitch.tv/oauth2/authorize?${params}`;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Invalid provider: ${input.provider}`);\n\t\t}\n\n\t\tthis.$zkLoginState.set({ provider: input.provider });\n\t\tif (this.#useNativeCryptoSigner) {\n\t\t\tawait set('ephemeralKeyPair', (ephemeralKeyPair as WebCryptoSigner).export(), this.#idbStore);\n\t\t}\n\n\t\tawait this.#setSession({\n\t\t\texpiresAt: estimatedExpiration,\n\t\t\tmaxEpoch,\n\t\t\trandomness,\n\t\t\tephemeralKeyPair: this.#useNativeCryptoSigner\n\t\t\t\t? '@@native'\n\t\t\t\t: toBase64(\n\t\t\t\t\t\tdecodeHaneulPrivateKey((ephemeralKeyPair as Ed25519Keypair).getSecretKey()).secretKey,\n\t\t\t\t\t),\n\t\t});\n\n\t\treturn oauthUrl;\n\t}\n\n\t// TODO: Should our SDK manage this automatically in addition to exposing a method?\n\tasync handleAuthCallback(hash: string = window.location.hash) {\n\t\tconst params = new URLSearchParams(hash.startsWith('#') ? hash.slice(1) : hash);\n\n\t\t// Before we handle the auth redirect and get the state, we need to restore it:\n\t\tconst zkp = await this.getSession();\n\n\t\tif (!zkp || !zkp.ephemeralKeyPair || !zkp.maxEpoch || !zkp.randomness) {\n\t\t\tthrow new Error(\n\t\t\t\t'Start of sign-in flow could not be found. Ensure you have started the sign-in flow before calling this.',\n\t\t\t);\n\t\t}\n\n\t\tconst jwt = params.get('id_token');\n\t\tif (!jwt) {\n\t\t\tthrow new Error('Missing ID Token');\n\t\t}\n\n\t\tdecodeJwt(jwt);\n\n\t\tconst { address, salt, publicKey } = await this.#enokiClient.getZkLogin({ jwt });\n\n\t\tthis.$zkLoginState.set({\n\t\t\t...this.$zkLoginState.get(),\n\t\t\tsalt,\n\t\t\taddress,\n\t\t\tpublicKey,\n\t\t});\n\t\tawait this.#setSession({\n\t\t\t...zkp,\n\t\t\tjwt,\n\t\t});\n\n\t\treturn params.get('state');\n\t}\n\n\tasync #setSession(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.#store.set(this.#storageKeys.SESSION, storedValue);\n\t\t} else {\n\t\t\tthis.#store.delete(this.#storageKeys.SESSION);\n\t\t}\n\n\t\tthis.$zkLoginSession.set({ initialized: true, value: newValue });\n\t}\n\n\tasync getSession() {\n\t\tif (this.$zkLoginSession.get().initialized) {\n\t\t\treturn this.$zkLoginSession.get().value;\n\t\t}\n\n\t\ttry {\n\t\t\tconst storedValue = this.#store.get(this.#storageKeys.SESSION);\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\t// TODO: Rather than having expiration act as a logout, we should keep the state that still is relevant,\n\t\t\t// and just clear out the expired session, but keep the other zkLogin state.\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\tthis.$zkLoginSession.set({ initialized: true, value: state });\n\t\t\t}\n\t\t} catch {\n\t\t\tthis.$zkLoginSession.set({ initialized: true, value: null });\n\t\t}\n\n\t\treturn this.$zkLoginSession.get().value;\n\t}\n\n\tasync logout() {\n\t\tthis.$zkLoginState.set({});\n\t\tthis.#store.delete(this.#storageKeys.STATE);\n\n\t\tif (this.#useNativeCryptoSigner) {\n\t\t\tawait clear(this.#idbStore);\n\t\t}\n\t\tawait this.#setSession(null);\n\t}\n\n\t// TODO: Should this return the proof if it already exists?\n\tasync getProof({ network }: { network?: EnokiNetwork } = {}) {\n\t\tconst zkp = await this.getSession();\n\t\tconst { salt } = this.$zkLoginState.get();\n\n\t\tif (zkp?.proof) {\n\t\t\tif (zkp.expiresAt && Date.now() > zkp.expiresAt) {\n\t\t\t\tthrow new Error('Stored proof is expired.');\n\t\t\t}\n\n\t\t\treturn zkp.proof;\n\t\t}\n\n\t\tif (!salt || !zkp || !zkp.jwt) {\n\t\t\tthrow new Error('Missing required parameters for proof generation');\n\t\t}\n\n\t\tlet storedNativeSigner: ExportedWebCryptoKeypair | undefined = undefined;\n\t\tif (this.#useNativeCryptoSigner && zkp.ephemeralKeyPair === '@@native') {\n\t\t\tstoredNativeSigner = await get('ephemeralKeyPair', this.#idbStore);\n\t\t\tif (!storedNativeSigner) {\n\t\t\t\tthrow new Error('Native signer not found in store.');\n\t\t\t}\n\t\t}\n\n\t\tconst ephemeralKeyPair =\n\t\t\tzkp.ephemeralKeyPair === '@@native'\n\t\t\t\t? WebCryptoSigner.import(storedNativeSigner!)\n\t\t\t\t: Ed25519Keypair.fromSecretKey(fromBase64(zkp.ephemeralKeyPair));\n\n\t\tconst proof = await this.#enokiClient.createZkLoginZkp({\n\t\t\tnetwork,\n\t\t\tjwt: zkp.jwt,\n\t\t\tmaxEpoch: zkp.maxEpoch,\n\t\t\trandomness: zkp.randomness,\n\t\t\tephemeralPublicKey: ephemeralKeyPair.getPublicKey(),\n\t\t});\n\n\t\tawait this.#setSession({\n\t\t\t...zkp,\n\t\t\tproof,\n\t\t});\n\n\t\treturn proof;\n\t}\n\n\tasync getKeypair({ network }: { network?: EnokiNetwork } = {}) {\n\t\t// Get the proof, so that we ensure it exists in state:\n\t\tawait this.getProof({ network });\n\n\t\tconst zkp = await this.getSession();\n\n\t\t// Check to see if we have the essentials for a keypair:\n\t\tconst { address } = this.$zkLoginState.get();\n\t\tif (!address || !zkp || !zkp.proof) {\n\t\t\tthrow new Error('Missing required data for keypair generation.');\n\t\t}\n\n\t\tif (Date.now() > zkp.expiresAt) {\n\t\t\tthrow new Error('Stored proof is expired.');\n\t\t}\n\n\t\tlet storedNativeSigner: ExportedWebCryptoKeypair | undefined = undefined;\n\t\tif (this.#useNativeCryptoSigner && zkp.ephemeralKeyPair === '@@native') {\n\t\t\tstoredNativeSigner = await get('ephemeralKeyPair', this.#idbStore);\n\t\t\tif (!storedNativeSigner) {\n\t\t\t\tthrow new Error('Native signer not found in store.');\n\t\t\t}\n\t\t}\n\n\t\tconst ephemeralKeypair =\n\t\t\tzkp.ephemeralKeyPair === '@@native'\n\t\t\t\t? WebCryptoSigner.import(storedNativeSigner!)\n\t\t\t\t: Ed25519Keypair.fromSecretKey(fromBase64(zkp.ephemeralKeyPair));\n\n\t\treturn new EnokiKeypair({\n\t\t\taddress,\n\t\t\tephemeralKeypair,\n\t\t\tmaxEpoch: zkp.maxEpoch,\n\t\t\tproof: zkp.proof,\n\t\t});\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAgC;AAChC,0BAAuC;AACvC,qBAA+B;AAC/B,mBAAqC;AACrC,qBAA0B;AAG1B,wBAA6C;AAE7C,wBAAqC;AAGrC,wBAAwC;AAExC,yBAA4B;AAE5B,0BAA6B;AAE7B,oBAAqC;AAtBrC;AAuEA,MAAM,oBAAoB,CAAC,YAAoB;AAAA,EAC9C,OAAO,qBAAqB,MAAM;AAAA,EAClC,SAAS,uBAAuB,MAAM;AACvC;AAKO,MAAM,UAAU;AAAA,EAYtB,YAAY,QAAyB;AAZ/B;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AAMC,uBAAK,cAAe,IAAI,+BAAY;AAAA,MACnC,QAAQ,OAAO;AAAA,MACf,QAAQ,OAAO;AAAA,MACf,kBAAkB,OAAO;AAAA,IAC1B,CAAC;AACD,uBAAK,gBAAiB,OAAO;AAE7B,QAAI,OAAO,iCA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AAI,OAAO;AACnC,YAAM,IAAI,MAAM,+CAA+C;AAAA,IAChE;AAEA,QAAI,KAAK,IAAI,IAAI,IAAI,WAAW;AAC/B,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC3C;AAEA,QAAI,qBAA2D;AAC/D,QAAI,mBAAK,2BAA0B,IAAI,qBAAqB,YAAY;AACvE,2BAAqB,UAAM,uBAAI,oBAAoB,mBAAK,UAAS;AACjE,UAAI,CAAC,oBAAoB;AACxB,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACpD;AAAA,IACD;AAEA,UAAM,mBACL,IAAI,qBAAqB,aACtB,iCAAgB,OAAO,kBAAmB,IAC1C,8BAAe,kBAAc,yBAAW,IAAI,gBAAgB,CAAC;AAEjE,WAAO,IAAI,iCAAa;AAAA,MACvB;AAAA,MACA;AAAA,MACA,UAAU,IAAI;AAAA,MACd,OAAO,IAAI;AAAA,IACZ,CAAC;AAAA,EACF;AACD;AA/SC;AACA;AACA;AACA;AACA;AACA;AACA;AAPM;AA0KA,gBAAW,eAAC,UAAiC;AAClD,MAAI,UAAU;AACb,UAAM,cAAc,MAAM,mBAAK,aAAY;AAAA,MAC1C,mBAAK;AAAA,MACL,KAAK,UAAU,QAAQ;AAAA,IACxB;AAEA,uBAAK,QAAO,IAAI,mBAAK,cAAa,SAAS,WAAW;AAAA,EACvD,OAAO;AACN,uBAAK,QAAO,OAAO,mBAAK,cAAa,OAAO;AAAA,EAC7C;AAEA,OAAK,gBAAgB,IAAI,EAAE,aAAa,MAAM,OAAO,SAAS,CAAC;AAChE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,20 @@
1
+ import type { SignatureWithBytes } from '@haneullabs/haneul/cryptography';
2
+ import { Signer } from '@haneullabs/haneul/cryptography';
3
+ import type { ZkLoginSignatureInputs } from '@haneullabs/haneul/zklogin';
4
+ import { ZkLoginPublicIdentifier } from '@haneullabs/haneul/zklogin';
5
+ export declare class EnokiPublicKey extends ZkLoginPublicIdentifier {
6
+ }
7
+ export declare class EnokiKeypair extends Signer {
8
+ #private;
9
+ constructor(input: {
10
+ address: string;
11
+ maxEpoch: number;
12
+ proof: ZkLoginSignatureInputs;
13
+ ephemeralKeypair: Signer;
14
+ });
15
+ sign(data: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
16
+ signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes>;
17
+ signTransaction(bytes: Uint8Array): Promise<SignatureWithBytes>;
18
+ getKeyScheme(): import("@haneullabs/haneul/cryptography").SignatureScheme;
19
+ getPublicKey(): EnokiPublicKey;
20
+ }
@@ -0,0 +1,87 @@
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 EnokiKeypair_exports = {};
27
+ __export(EnokiKeypair_exports, {
28
+ EnokiKeypair: () => EnokiKeypair,
29
+ EnokiPublicKey: () => EnokiPublicKey
30
+ });
31
+ module.exports = __toCommonJS(EnokiKeypair_exports);
32
+ var import_cryptography = require("@haneullabs/haneul/cryptography");
33
+ var import_zklogin = require("@haneullabs/haneul/zklogin");
34
+ var _proof, _maxEpoch, _ephemeralKeypair, _publicKey;
35
+ class EnokiPublicKey extends import_zklogin.ZkLoginPublicIdentifier {
36
+ }
37
+ class EnokiKeypair extends import_cryptography.Signer {
38
+ constructor(input) {
39
+ super();
40
+ __privateAdd(this, _proof);
41
+ __privateAdd(this, _maxEpoch);
42
+ __privateAdd(this, _ephemeralKeypair);
43
+ __privateAdd(this, _publicKey);
44
+ __privateSet(this, _proof, input.proof);
45
+ __privateSet(this, _maxEpoch, input.maxEpoch);
46
+ __privateSet(this, _ephemeralKeypair, input.ephemeralKeypair);
47
+ __privateSet(this, _publicKey, EnokiPublicKey.fromProof(input.address, input.proof));
48
+ }
49
+ async sign(data) {
50
+ return __privateGet(this, _ephemeralKeypair).sign(data);
51
+ }
52
+ async signPersonalMessage(bytes) {
53
+ const { bytes: signedBytes, signature: userSignature } = await __privateGet(this, _ephemeralKeypair).signPersonalMessage(bytes);
54
+ const zkSignature = (0, import_zklogin.getZkLoginSignature)({
55
+ inputs: __privateGet(this, _proof),
56
+ maxEpoch: __privateGet(this, _maxEpoch),
57
+ userSignature
58
+ });
59
+ return {
60
+ bytes: signedBytes,
61
+ signature: zkSignature
62
+ };
63
+ }
64
+ async signTransaction(bytes) {
65
+ const { bytes: signedBytes, signature: userSignature } = await __privateGet(this, _ephemeralKeypair).signTransaction(bytes);
66
+ const zkSignature = (0, import_zklogin.getZkLoginSignature)({
67
+ inputs: __privateGet(this, _proof),
68
+ maxEpoch: __privateGet(this, _maxEpoch),
69
+ userSignature
70
+ });
71
+ return {
72
+ bytes: signedBytes,
73
+ signature: zkSignature
74
+ };
75
+ }
76
+ getKeyScheme() {
77
+ return __privateGet(this, _ephemeralKeypair).getKeyScheme();
78
+ }
79
+ getPublicKey() {
80
+ return __privateGet(this, _publicKey);
81
+ }
82
+ }
83
+ _proof = new WeakMap();
84
+ _maxEpoch = new WeakMap();
85
+ _ephemeralKeypair = new WeakMap();
86
+ _publicKey = new WeakMap();
87
+ //# sourceMappingURL=EnokiKeypair.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/EnokiKeypair.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SignatureWithBytes } from '@haneullabs/haneul/cryptography';\nimport { Signer } from '@haneullabs/haneul/cryptography';\nimport type { ZkLoginSignatureInputs } from '@haneullabs/haneul/zklogin';\nimport { getZkLoginSignature, ZkLoginPublicIdentifier } from '@haneullabs/haneul/zklogin';\n\nexport class EnokiPublicKey extends ZkLoginPublicIdentifier {}\n\nexport class EnokiKeypair extends Signer {\n\t#proof: ZkLoginSignatureInputs;\n\t#maxEpoch: number;\n\t#ephemeralKeypair: Signer;\n\t#publicKey: EnokiPublicKey;\n\n\tconstructor(input: {\n\t\taddress: string;\n\t\tmaxEpoch: number;\n\t\tproof: ZkLoginSignatureInputs;\n\t\tephemeralKeypair: Signer;\n\t}) {\n\t\tsuper();\n\t\tthis.#proof = input.proof;\n\t\tthis.#maxEpoch = input.maxEpoch;\n\t\tthis.#ephemeralKeypair = input.ephemeralKeypair;\n\t\tthis.#publicKey = EnokiPublicKey.fromProof(input.address, input.proof);\n\t}\n\n\tasync sign(data: Uint8Array) {\n\t\treturn this.#ephemeralKeypair.sign(data);\n\t}\n\n\tasync signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes> {\n\t\tconst { bytes: signedBytes, signature: userSignature } =\n\t\t\tawait this.#ephemeralKeypair.signPersonalMessage(bytes);\n\n\t\tconst zkSignature = getZkLoginSignature({\n\t\t\tinputs: this.#proof,\n\t\t\tmaxEpoch: this.#maxEpoch,\n\t\t\tuserSignature,\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: signedBytes,\n\t\t\tsignature: zkSignature,\n\t\t};\n\t}\n\n\tasync signTransaction(bytes: Uint8Array): Promise<SignatureWithBytes> {\n\t\tconst { bytes: signedBytes, signature: userSignature } =\n\t\t\tawait this.#ephemeralKeypair.signTransaction(bytes);\n\n\t\tconst zkSignature = getZkLoginSignature({\n\t\t\tinputs: this.#proof,\n\t\t\tmaxEpoch: this.#maxEpoch,\n\t\t\tuserSignature,\n\t\t});\n\n\t\treturn {\n\t\t\tbytes: signedBytes,\n\t\t\tsignature: zkSignature,\n\t\t};\n\t}\n\n\tgetKeyScheme() {\n\t\treturn this.#ephemeralKeypair.getKeyScheme();\n\t}\n\n\tgetPublicKey() {\n\t\treturn this.#publicKey;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAuB;AAEvB,qBAA6D;AAN7D;AAQO,MAAM,uBAAuB,uCAAwB;AAAC;AAEtD,MAAM,qBAAqB,2BAAO;AAAA,EAMxC,YAAY,OAKT;AACF,UAAM;AAXP;AACA;AACA;AACA;AASC,uBAAK,QAAS,MAAM;AACpB,uBAAK,WAAY,MAAM;AACvB,uBAAK,mBAAoB,MAAM;AAC/B,uBAAK,YAAa,eAAe,UAAU,MAAM,SAAS,MAAM,KAAK;AAAA,EACtE;AAAA,EAEA,MAAM,KAAK,MAAkB;AAC5B,WAAO,mBAAK,mBAAkB,KAAK,IAAI;AAAA,EACxC;AAAA,EAEA,MAAM,oBAAoB,OAAgD;AACzE,UAAM,EAAE,OAAO,aAAa,WAAW,cAAc,IACpD,MAAM,mBAAK,mBAAkB,oBAAoB,KAAK;AAEvD,UAAM,kBAAc,oCAAoB;AAAA,MACvC,QAAQ,mBAAK;AAAA,MACb,UAAU,mBAAK;AAAA,MACf;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,MAAM,gBAAgB,OAAgD;AACrE,UAAM,EAAE,OAAO,aAAa,WAAW,cAAc,IACpD,MAAM,mBAAK,mBAAkB,gBAAgB,KAAK;AAEnD,UAAM,kBAAc,oCAAoB;AAAA,MACvC,QAAQ,mBAAK;AAAA,MACb,UAAU,mBAAK;AAAA,MACf;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EAEA,eAAe;AACd,WAAO,mBAAK,mBAAkB,aAAa;AAAA,EAC5C;AAAA,EAEA,eAAe;AACd,WAAO,mBAAK;AAAA,EACb;AACD;AA7DC;AACA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A general interface for specifying how data should be encrypted and decrypted.
3
+ */
4
+ export interface Encryption {
5
+ encrypt(password: string, data: string): Promise<string>;
6
+ decrypt(password: string, data: string): Promise<string>;
7
+ }
8
+ /**
9
+ * Create the default encryption interface, which uses the browsers built-in crypto primitives.
10
+ */
11
+ export declare function createDefaultEncryption(): Encryption;
12
+ /**
13
+ * Create a passthrough encryption interface, which does not encrypt or decrypt data.
14
+ */
15
+ export declare function createPassthroughEncryption(): Encryption;
@@ -0,0 +1,96 @@
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 encryption_exports = {};
20
+ __export(encryption_exports, {
21
+ createDefaultEncryption: () => createDefaultEncryption,
22
+ createPassthroughEncryption: () => createPassthroughEncryption
23
+ });
24
+ module.exports = __toCommonJS(encryption_exports);
25
+ var import_utils = require("@haneullabs/haneul/utils");
26
+ function createDefaultEncryption() {
27
+ async function keyFromPassword(password, salt) {
28
+ const key = await crypto.subtle.importKey(
29
+ "raw",
30
+ new TextEncoder().encode(password),
31
+ { name: "PBKDF2" },
32
+ false,
33
+ ["deriveBits", "deriveKey"]
34
+ );
35
+ const derivedKey = await crypto.subtle.deriveKey(
36
+ {
37
+ name: "PBKDF2",
38
+ salt,
39
+ iterations: 9e5,
40
+ hash: "SHA-256"
41
+ },
42
+ key,
43
+ { name: "AES-GCM", length: 256 },
44
+ false,
45
+ ["encrypt", "decrypt"]
46
+ );
47
+ return { key, derivedKey };
48
+ }
49
+ return {
50
+ async encrypt(password, data) {
51
+ const salt = crypto.getRandomValues(new Uint8Array(16));
52
+ const iv = crypto.getRandomValues(new Uint8Array(12));
53
+ const { derivedKey } = await keyFromPassword(password, salt);
54
+ const payload = await crypto.subtle.encrypt(
55
+ {
56
+ name: "AES-GCM",
57
+ iv
58
+ },
59
+ derivedKey,
60
+ new TextEncoder().encode(data)
61
+ );
62
+ return JSON.stringify({
63
+ payload: (0, import_utils.toBase64)(new Uint8Array(payload)),
64
+ iv: (0, import_utils.toBase64)(iv),
65
+ salt: (0, import_utils.toBase64)(salt)
66
+ });
67
+ },
68
+ async decrypt(password, data) {
69
+ const parsed = JSON.parse(data);
70
+ if (!parsed.payload || !parsed.iv || !parsed.salt) {
71
+ throw new Error("Invalid encrypted data");
72
+ }
73
+ const { derivedKey } = await keyFromPassword(password, (0, import_utils.fromBase64)(parsed.salt));
74
+ const decryptedContent = await crypto.subtle.decrypt(
75
+ {
76
+ name: "AES-GCM",
77
+ iv: (0, import_utils.fromBase64)(parsed.iv)
78
+ },
79
+ derivedKey,
80
+ (0, import_utils.fromBase64)(parsed.payload)
81
+ );
82
+ return new TextDecoder().decode(decryptedContent);
83
+ }
84
+ };
85
+ }
86
+ function createPassthroughEncryption() {
87
+ return {
88
+ async encrypt(_password, data) {
89
+ return data;
90
+ },
91
+ async decrypt(_password, data) {
92
+ return data;
93
+ }
94
+ };
95
+ }
96
+ //# sourceMappingURL=encryption.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/encryption.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64 } from '@haneullabs/haneul/utils';\n\n/**\n * A general interface for specifying how data should be encrypted and decrypted.\n */\nexport interface Encryption {\n\tencrypt(password: string, data: string): Promise<string>;\n\tdecrypt(password: string, data: string): Promise<string>;\n}\n\n/**\n * Create the default encryption interface, which uses the browsers built-in crypto primitives.\n */\nexport function createDefaultEncryption(): Encryption {\n\ttype EncryptedJSON = {\n\t\tpayload: string;\n\t\tiv: string;\n\t\tsalt: string;\n\t};\n\n\tasync function keyFromPassword(password: string, salt: Uint8Array) {\n\t\tconst key = await crypto.subtle.importKey(\n\t\t\t'raw',\n\t\t\tnew TextEncoder().encode(password),\n\t\t\t{ name: 'PBKDF2' },\n\t\t\tfalse,\n\t\t\t['deriveBits', 'deriveKey'],\n\t\t);\n\n\t\tconst derivedKey = await crypto.subtle.deriveKey(\n\t\t\t{\n\t\t\t\tname: 'PBKDF2',\n\t\t\t\tsalt: salt as BufferSource,\n\t\t\t\titerations: 900_000,\n\t\t\t\thash: 'SHA-256',\n\t\t\t},\n\t\t\tkey,\n\t\t\t{ name: 'AES-GCM', length: 256 },\n\t\t\tfalse,\n\t\t\t['encrypt', 'decrypt'],\n\t\t);\n\n\t\treturn { key, derivedKey };\n\t}\n\n\treturn {\n\t\tasync encrypt(password, data) {\n\t\t\tconst salt = crypto.getRandomValues(new Uint8Array(16));\n\t\t\tconst iv = crypto.getRandomValues(new Uint8Array(12));\n\n\t\t\tconst { derivedKey } = await keyFromPassword(password, salt);\n\n\t\t\tconst payload = await crypto.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\tname: 'AES-GCM',\n\t\t\t\t\tiv,\n\t\t\t\t},\n\t\t\t\tderivedKey,\n\t\t\t\tnew TextEncoder().encode(data),\n\t\t\t);\n\n\t\t\treturn JSON.stringify({\n\t\t\t\tpayload: toBase64(new Uint8Array(payload)),\n\t\t\t\tiv: toBase64(iv),\n\t\t\t\tsalt: toBase64(salt),\n\t\t\t} satisfies EncryptedJSON);\n\t\t},\n\t\tasync decrypt(password, data) {\n\t\t\tconst parsed = JSON.parse(data) as EncryptedJSON;\n\t\t\tif (!parsed.payload || !parsed.iv || !parsed.salt) {\n\t\t\t\tthrow new Error('Invalid encrypted data');\n\t\t\t}\n\n\t\t\tconst { derivedKey } = await keyFromPassword(password, fromBase64(parsed.salt));\n\n\t\t\tconst decryptedContent = await crypto.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\tname: 'AES-GCM',\n\t\t\t\t\tiv: fromBase64(parsed.iv),\n\t\t\t\t},\n\t\t\t\tderivedKey,\n\t\t\t\tfromBase64(parsed.payload),\n\t\t\t);\n\n\t\t\treturn new TextDecoder().decode(decryptedContent);\n\t\t},\n\t};\n}\n\n/**\n * Create a passthrough encryption interface, which does not encrypt or decrypt data.\n */\nexport function createPassthroughEncryption(): Encryption {\n\treturn {\n\t\tasync encrypt(_password, data) {\n\t\t\treturn data;\n\t\t},\n\t\tasync decrypt(_password, data) {\n\t\t\treturn data;\n\t\t},\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAqC;AAa9B,SAAS,0BAAsC;AAOrD,iBAAe,gBAAgB,UAAk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,yBAAW,OAAO,IAAI,CAAC;AAE9E,YAAM,mBAAmB,MAAM,OAAO,OAAO;AAAA,QAC5C;AAAA,UACC,MAAM;AAAA,UACN,QAAI,yBAAW,OAAO,EAAE;AAAA,QACzB;AAAA,QACA;AAAA,YACA,yBAAW,OAAO,OAAO;AAAA,MAC1B;AAEA,aAAO,IAAI,YAAY,EAAE,OAAO,gBAAgB;AAAA,IACjD;AAAA,EACD;AACD;AAKO,SAAS,8BAA0C;AACzD,SAAO;AAAA,IACN,MAAM,QAAQ,WAAW,MAAM;AAC9B,aAAO;AAAA,IACR;AAAA,IACA,MAAM,QAAQ,WAAW,MAAM;AAC9B,aAAO;AAAA,IACR;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ export { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';
2
+ export type { EnokiNetwork, AuthProvider } from './EnokiClient/type.js';
3
+ export { EnokiFlow, type EnokiFlowConfig } from './EnokiFlow.js';
4
+ export { createLocalStorage, createSessionStorage, createInMemoryStorage, type SyncStore, } from './stores.js';
5
+ export { createDefaultEncryption, type Encryption } from './encryption.js';
6
+ export { EnokiKeypair, EnokiPublicKey } from './EnokiKeypair.js';
7
+ export type { EnokiWallet } from './wallet/wallet.js';
8
+ export { registerEnokiWallets } from './wallet/register.js';
9
+ export { enokiWalletsInitializer } from './wallet/initializer.js';
10
+ export { isEnokiWallet, isGoogleWallet, isTwitchWallet, isFacebookWallet, getWalletMetadata, getSession, } from './wallet/utils.js';
11
+ export { type RegisterEnokiWalletsOptions } from './wallet/types.js';
12
+ export { isEnokiNetwork } from './utils.js';
@@ -0,0 +1,50 @@
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 index_exports = {};
20
+ __export(index_exports, {
21
+ EnokiClient: () => import_EnokiClient.EnokiClient,
22
+ EnokiClientError: () => import_EnokiClient.EnokiClientError,
23
+ EnokiFlow: () => import_EnokiFlow.EnokiFlow,
24
+ EnokiKeypair: () => import_EnokiKeypair.EnokiKeypair,
25
+ EnokiPublicKey: () => import_EnokiKeypair.EnokiPublicKey,
26
+ createDefaultEncryption: () => import_encryption.createDefaultEncryption,
27
+ createInMemoryStorage: () => import_stores.createInMemoryStorage,
28
+ createLocalStorage: () => import_stores.createLocalStorage,
29
+ createSessionStorage: () => import_stores.createSessionStorage,
30
+ enokiWalletsInitializer: () => import_initializer.enokiWalletsInitializer,
31
+ getSession: () => import_utils.getSession,
32
+ getWalletMetadata: () => import_utils.getWalletMetadata,
33
+ isEnokiNetwork: () => import_utils2.isEnokiNetwork,
34
+ isEnokiWallet: () => import_utils.isEnokiWallet,
35
+ isFacebookWallet: () => import_utils.isFacebookWallet,
36
+ isGoogleWallet: () => import_utils.isGoogleWallet,
37
+ isTwitchWallet: () => import_utils.isTwitchWallet,
38
+ registerEnokiWallets: () => import_register.registerEnokiWallets
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+ var import_EnokiClient = require("./EnokiClient/index.js");
42
+ var import_EnokiFlow = require("./EnokiFlow.js");
43
+ var import_stores = require("./stores.js");
44
+ var import_encryption = require("./encryption.js");
45
+ var import_EnokiKeypair = require("./EnokiKeypair.js");
46
+ var import_register = require("./wallet/register.js");
47
+ var import_initializer = require("./wallet/initializer.js");
48
+ var import_utils = require("./wallet/utils.js");
49
+ var import_utils2 = require("./utils.js");
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';\nexport type { EnokiNetwork, AuthProvider } from './EnokiClient/type.js';\nexport { EnokiFlow, type EnokiFlowConfig } from './EnokiFlow.js';\nexport {\n\tcreateLocalStorage,\n\tcreateSessionStorage,\n\tcreateInMemoryStorage,\n\ttype SyncStore,\n} from './stores.js';\nexport { createDefaultEncryption, type Encryption } from './encryption.js';\nexport { EnokiKeypair, EnokiPublicKey } from './EnokiKeypair.js';\n\nexport type { EnokiWallet } from './wallet/wallet.js';\nexport { registerEnokiWallets } from './wallet/register.js';\nexport { enokiWalletsInitializer } from './wallet/initializer.js';\n\nexport {\n\tisEnokiWallet,\n\tisGoogleWallet,\n\tisTwitchWallet,\n\tisFacebookWallet,\n\tgetWalletMetadata,\n\tgetSession,\n} from './wallet/utils.js';\nexport { type RegisterEnokiWalletsOptions } from './wallet/types.js';\n\nexport { isEnokiNetwork } from './utils.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAsE;AAEtE,uBAAgD;AAChD,oBAKO;AACP,wBAAyD;AACzD,0BAA6C;AAG7C,sBAAqC;AACrC,yBAAwC;AAExC,mBAOO;AAGP,IAAAA,gBAA+B;",
6
+ "names": ["import_utils"]
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "private": true,
3
+ "type": "commonjs"
4
+ }