@etherplay/connect-core 0.5.0 → 0.7.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/dist/access.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type AllowlistLookup, type DelegationTarget } from './permissions.js';
2
+ import type { OriginApprovalRequest, PermissionRequest } from './types.js';
2
3
  /**
3
4
  * WHO MAY ASK FOR AN ACCOUNT THAT IS NOT THEIRS.
4
5
  *
@@ -147,6 +148,57 @@ export declare function confirmAccess(decision: AccessDecision, confirmationsGiv
147
148
  };
148
149
  /** How many confirmations this decision needs, for a UI that wants to say so. */
149
150
  export declare function confirmationsRequired(decision: AccessDecision): number;
151
+ /**
152
+ * THE TWO ORIGINS OF ONE SIGN-IN, AND WHAT THE APP ASKED FOR, AS ONE VALUE.
153
+ *
154
+ * They travel together everywhere: into a provider, into the approval gate, into the access
155
+ * decision, and into delivery. Named as one thing because they are two strings of the same type
156
+ * meaning OPPOSITE sides of the same question - who is asking, and whose account is at stake - and
157
+ * as positional arguments they are silently swappable. Swapping them does not fail: it produces a
158
+ * host that decides access for the wrong pair and hands the result to the wrong window.
159
+ */
160
+ export type OriginContext = {
161
+ /** the origin that opened the window, as it claimed to be */
162
+ windowOrigin: string;
163
+ /** the origin being signed for */
164
+ signingOrigin: string;
165
+ /** what the app declared at connect time; empty or absent when it asked for nothing */
166
+ permissions?: PermissionRequest[];
167
+ };
168
+ /**
169
+ * What has to be settled before a result may be handed to the opener.
170
+ *
171
+ * PROVIDER-AGNOSTIC, and here rather than in a provider because every provider needs the SAME
172
+ * answer. When it lived in one provider the three sign-in paths disagreed: the mnemonic one raised
173
+ * the access gate and the email and oauth ones passed `false`, so signing in by email skipped an
174
+ * approval that signing in by mnemonic required. A gate that only some doors have is not a gate.
175
+ *
176
+ * `false` only when there is nothing at all to settle. Anything else and the UI must ask, and the
177
+ * host must withhold the result until it has.
178
+ */
179
+ export declare function originApprovalRequired(request: OriginContext): false | OriginApprovalRequest;
180
+ /**
181
+ * THE MISMATCH THAT COSTS AN AFTERNOON, described so a host can say it out loud.
182
+ *
183
+ * The host posts its result with `postMessage(..., {targetOrigin: windowOrigin})`, where
184
+ * `windowOrigin` is what the opener CLAIMED to be. That origin lock is load-bearing and must not be
185
+ * relaxed: it is the whole reason a page that lies about its origin gains nothing, because the
186
+ * browser then delivers the account only to a window actually at the claimed origin.
187
+ *
188
+ * The cost of that guarantee is a failure mode with no error anywhere. If the claim is not the
189
+ * opener's real origin - `http://127.0.0.1:5173` against `http://localhost:5173`, http against
190
+ * https, or the wrong port - the sign-in completes visibly in the popup and the browser silently
191
+ * drops the result. The app waits forever and nothing on either side says why.
192
+ *
193
+ * Here rather than in the host, and pure, because it is a comparison of two origin strings by the
194
+ * same spelling rules as everything else in this file, and because a comparison a host writes for
195
+ * itself is one nobody tests. `undefined` when they agree, or when there is nothing to compare
196
+ * against: absence of a real origin means CANNOT TELL, never MISMATCH.
197
+ */
198
+ export declare function describeOriginMismatch(claimed: string | undefined | null, opener: string | undefined | null): {
199
+ message: string;
200
+ brief: string;
201
+ } | undefined;
150
202
  /**
151
203
  * Which (chain, contract) pairs may be signed with NOBODY IN THE LOOP, given how access was decided.
152
204
  *
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;AAE1G;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACvB;IAAC,IAAI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CAAkC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,GAAG,qBAAqB,CAe5F;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAClC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC/B;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,GAAG,SAAS,CAmC9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,gBAAgB,EAAE,CAAC;CACrD,GAAG,eAAe,CAYlB"}
package/dist/access.js CHANGED
@@ -136,6 +136,86 @@ export function confirmAccess(decision, confirmationsGiven) {
136
136
  export function confirmationsRequired(decision) {
137
137
  return requiresSecondConfirmation(decision) ? 2 : 1;
138
138
  }
139
+ /**
140
+ * What has to be settled before a result may be handed to the opener.
141
+ *
142
+ * PROVIDER-AGNOSTIC, and here rather than in a provider because every provider needs the SAME
143
+ * answer. When it lived in one provider the three sign-in paths disagreed: the mnemonic one raised
144
+ * the access gate and the email and oauth ones passed `false`, so signing in by email skipped an
145
+ * approval that signing in by mnemonic required. A gate that only some doors have is not a gate.
146
+ *
147
+ * `false` only when there is nothing at all to settle. Anything else and the UI must ask, and the
148
+ * host must withhold the result until it has.
149
+ */
150
+ export function originApprovalRequired(request) {
151
+ const permissions = request.permissions || [];
152
+ // The SAME comparison the access decision uses, rather than a `!==` written again here. This does
153
+ // not decide access; all it does is notice there is nothing at all to settle, and it must not
154
+ // reach that conclusion by a rule stricter or looser than the one that would have decided the
155
+ // request.
156
+ const sameOrigin = normalizeOrigin(request.windowOrigin) === normalizeOrigin(request.signingOrigin);
157
+ if (sameOrigin && permissions.length === 0) {
158
+ return false;
159
+ }
160
+ return {
161
+ windowOrigin: request.windowOrigin,
162
+ signingOrigin: request.signingOrigin,
163
+ permissions,
164
+ };
165
+ }
166
+ /** Loopback names that are the same machine and NOT the same origin, which is the whole trap. */
167
+ const LOOPBACK_ALIASES = ['localhost', '127.0.0.1', '[::1]'];
168
+ /**
169
+ * THE MISMATCH THAT COSTS AN AFTERNOON, described so a host can say it out loud.
170
+ *
171
+ * The host posts its result with `postMessage(..., {targetOrigin: windowOrigin})`, where
172
+ * `windowOrigin` is what the opener CLAIMED to be. That origin lock is load-bearing and must not be
173
+ * relaxed: it is the whole reason a page that lies about its origin gains nothing, because the
174
+ * browser then delivers the account only to a window actually at the claimed origin.
175
+ *
176
+ * The cost of that guarantee is a failure mode with no error anywhere. If the claim is not the
177
+ * opener's real origin - `http://127.0.0.1:5173` against `http://localhost:5173`, http against
178
+ * https, or the wrong port - the sign-in completes visibly in the popup and the browser silently
179
+ * drops the result. The app waits forever and nothing on either side says why.
180
+ *
181
+ * Here rather than in the host, and pure, because it is a comparison of two origin strings by the
182
+ * same spelling rules as everything else in this file, and because a comparison a host writes for
183
+ * itself is one nobody tests. `undefined` when they agree, or when there is nothing to compare
184
+ * against: absence of a real origin means CANNOT TELL, never MISMATCH.
185
+ */
186
+ export function describeOriginMismatch(claimed, opener) {
187
+ if (!claimed || !opener) {
188
+ return undefined;
189
+ }
190
+ let claimedOrigin;
191
+ let openerOrigin;
192
+ try {
193
+ claimedOrigin = new URL(normalizeOrigin(claimed)).origin;
194
+ openerOrigin = new URL(normalizeOrigin(opener)).origin;
195
+ }
196
+ catch {
197
+ return undefined;
198
+ }
199
+ if (claimedOrigin === openerOrigin) {
200
+ return undefined;
201
+ }
202
+ const claimedHost = new URL(claimedOrigin).hostname;
203
+ const openerHost = new URL(openerOrigin).hostname;
204
+ // DIFFERENT loopback spellings. Same spelling on a different scheme or port is a mismatch too,
205
+ // but saying `"localhost" and "localhost" are not interchangeable` about it would be nonsense,
206
+ // and a message that is nonsense in one case is a message people stop reading in every case.
207
+ const bothLoopback = claimedHost !== openerHost && LOOPBACK_ALIASES.includes(claimedHost) && LOOPBACK_ALIASES.includes(openerHost);
208
+ return {
209
+ brief: `[etherplay] delivering to "${claimedOrigin}", which is not where the opener is ("${openerOrigin}"): the browser will drop this.`,
210
+ message: `[etherplay] ORIGIN MISMATCH: the page that opened this window declared "${claimedOrigin}" but is actually at ` +
211
+ `"${openerOrigin}". The result is delivered with that declared origin as postMessage's targetOrigin, so the ` +
212
+ `browser will drop it and the app will receive NOTHING, with no error of its own.` +
213
+ (bothLoopback
214
+ ? ` These two are the same machine and different origins: "${claimedHost}" and "${openerHost}" are not ` +
215
+ `interchangeable here. Open your app on "${openerHost}" or configure it to use the other, but use one.`
216
+ : ` Whatever the app passes as its origin must be exactly the origin it is served from.`),
217
+ };
218
+ }
139
219
  /**
140
220
  * Which (chain, contract) pairs may be signed with NOBODY IN THE LOOP, given how access was decided.
141
221
  *
@@ -1 +1 @@
1
- {"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAA8C,MAAM,kBAAkB,CAAC;AAsE9F,MAAM,UAAU,uBAAuB,CAAC,OAAsD;IAC7F,OAAO;QACN,0FAA0F;QAC1F,6EAA6E;QAC7E,OAAO,EAAE,GAAG,OAAO,CAAC,YAAY,mCAAmC,OAAO,CAAC,aAAa,EAAE;QAC1F,IAAI,EAAE,sBAAsB;QAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,aAAa,EAAE,OAAO,CAAC,aAAa;KACpC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;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ACN,2EAA2E,aAAa,uBAAuB;YAC/G,IAAI,YAAY,6FAA6F;YAC7G,kFAAkF;YAClF,CAAC,YAAY;gBACZ,CAAC,CAAC,2DAA2D,WAAW,UAAU,UAAU,YAAY;oBACvG,2CAA2C,UAAU,kDAAkD;gBACxG,CAAC,CAAC,sFAAsF,CAAC;KAC3F,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,OAK9B;IACA,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3C,OAAO,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QACvE,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/F,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5F,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACpB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -39,4 +39,5 @@ export * from './crypto.js';
39
39
  export * from './permissions.js';
40
40
  export * from './access.js';
41
41
  export * from './oauth-callback.js';
42
+ export * from './local-provider.js';
42
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAA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;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -91,7 +91,6 @@ export async function deriveOriginAccount(origin, account, accountGenerator, gra
91
91
  publicKey: originAccount.publicKey,
92
92
  address: originAccount.address,
93
93
  privateKey: originAccount.privateKey,
94
- mnemonicKey: originKey,
95
94
  },
96
95
  metadata: {},
97
96
  mechanismUsed: account.signer.mechanismUsed,
@@ -154,4 +153,5 @@ export * from './crypto.js';
154
153
  export * from './permissions.js';
155
154
  export * from './access.js';
156
155
  export * from './oauth-callback.js';
156
+ export * from './local-provider.js';
157
157
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AACnE,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAIxD,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,WAAW,IAAI,mIAAmI,CAAC;AAC3J,CAAC;AACD,MAAM,UAAU,eAAe;IAC9B,OAAO,mGAAmG,CAAC;AAC5G,CAAC;AACD,MAAM,UAAU,iCAAiC,CAAC,IAAY,EAAE,SAAwB;IACvF,OAAO,WAAW,IAAI,2HAA2H,SAAS,0EAA0E,CAAC;AACtO,CAAC;AACD,qFAAqF;AACrF,kGAAkG;AAClG,+FAA+F;AAC/F,8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,MAAM,UAAU,aAAa,CAAC,GAAwB;IACrD,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe;AAClE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAwB;IACtD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC;AAID,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { AccountGenerator } from '@etherplay/wallet-connector';
2
+ import { type OriginContext } from './access.js';
3
+ import type { AuthProvider } from './types.js';
4
+ export type LocalProviderSettings = OriginContext & {
5
+ accountGenerator: AccountGenerator;
6
+ };
7
+ export declare function createLocalProvider(settings: LocalProviderSettings): AuthProvider;
8
+ //# sourceMappingURL=local-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-provider.d.ts","sourceRoot":"","sources":["../src/local-provider.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAyB,KAAK,aAAa,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAEX,YAAY,EAMZ,MAAM,YAAY,CAAC;AAKpB,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IACnD,gBAAgB,EAAE,gBAAgB,CAAC;CACnC,CAAC;AAyCF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,YAAY,CAoGjF"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * AN ACCOUNT WHOSE KEY COMES FROM THIS BROWSER AND NO SERVICE.
3
+ *
4
+ * Named `local` rather than `mnemonic` because what defines it is the ABSENCE of a service, not the
5
+ * mechanism: a raw private key, or a key from hardware, would belong here too. Today it implements
6
+ * exactly one mechanism.
7
+ *
8
+ * It used to be a branch inside `@etherplay/openfort`, where it touched `openfortInstance` nowhere
9
+ * and needed neither a publishable key nor a network. Living there meant a vendor SDK was
10
+ * constructed on a path that never called it, so a vendor version bump could break a sign-in that
11
+ * does not involve the vendor, and the failure would have looked like an application bug.
12
+ *
13
+ * WHY IN connect-core AND NOT A PACKAGE OF ITS OWN. Everything this file needs - the derivation, the
14
+ * mechanism types, the approval question - is already here, and a separate package would be one
15
+ * more version to keep in lockstep with this one. When the two drift, a tree ends up with two
16
+ * copies of the derivation resolved at two versions, which is the exact failure `@etherplay/delegation`
17
+ * was created to end. `@etherplay/openfort` is a separate package because it drags a vendor SDK;
18
+ * this drags nothing.
19
+ *
20
+ * An app that only uses `@etherplay/connect` never references it, and this package declares
21
+ * `"sideEffects": false`, which is what lets a bundler drop it rather than merely permitting it to
22
+ * in principle. Nothing here runs at import time.
23
+ */
24
+ import { mnemonicToEntropy } from '@scure/bip39';
25
+ import { wordlist } from '@scure/bip39/wordlists/english';
26
+ import { bytesToHex } from '@noble/hashes/utils';
27
+ import { originApprovalRequired } from './access.js';
28
+ /**
29
+ * The smallest store that satisfies the contract `AuthProvider` extends.
30
+ *
31
+ * Written here rather than depended on, because it is fifteen lines and this package deliberately
32
+ * has no store library, no framework and no browser globals in its dependency list.
33
+ */
34
+ function createStateStore(initial) {
35
+ let current = initial;
36
+ const subscribers = new Set();
37
+ return {
38
+ subscribe(run) {
39
+ subscribers.add(run);
40
+ // Called immediately with the current value: the store contract every Svelte consumer,
41
+ // including `$authProvider` in the host, relies on.
42
+ run(current);
43
+ return () => {
44
+ subscribers.delete(run);
45
+ };
46
+ },
47
+ set(state) {
48
+ current = state;
49
+ for (const run of [...subscribers]) {
50
+ run(current);
51
+ }
52
+ },
53
+ get() {
54
+ return current;
55
+ },
56
+ };
57
+ }
58
+ /** Said the same way by every method that cannot do its job here, so the reason is never a guess. */
59
+ function notLocal(what) {
60
+ return new Error(`${what} is hosted authentication and the local provider has no host: it derives the account from a mnemonic in this browser. ` +
61
+ `Route this mechanism to a hosted provider (the host does this by mechanism, not by the "provider" query parameter).`);
62
+ }
63
+ export function createLocalProvider(settings) {
64
+ const store = createStateStore({ step: 'Idle' });
65
+ /**
66
+ * Nothing to initialise, and that is the property worth keeping.
67
+ *
68
+ * No key, no SDK, no network: a mnemonic sign-in completes in a host built with no vendor
69
+ * credentials at all, offline, over plain http. The two steps are still emitted so the host's
70
+ * UI sees the same sequence it sees from a hosted provider.
71
+ */
72
+ async function init(_providerSettings) {
73
+ store.set({ step: 'Initialising', auto: true });
74
+ store.set({ step: 'Initialised' });
75
+ }
76
+ async function connect(mechanism, _redirection) {
77
+ if (mechanism.type !== 'mnemonic') {
78
+ throw notLocal(`"${mechanism.type}"`);
79
+ }
80
+ if (mechanism.index === undefined) {
81
+ store.set({
82
+ step: 'MnemonicIndexToProvide',
83
+ mechanism: { type: 'mnemonic', mnemonic: mechanism.mnemonic, index: undefined },
84
+ });
85
+ return;
86
+ }
87
+ store.set({ step: 'GeneratingAccount', mechanism });
88
+ const mnemonic = mechanism.mnemonic;
89
+ const index = mechanism.index ?? 0;
90
+ const viemAccount = settings.accountGenerator.fromMnemonicToAccount(mnemonic, index);
91
+ const keyUint8Array = mnemonicToEntropy(mnemonic, wordlist);
92
+ const key = `0x${bytesToHex(keyUint8Array)}`;
93
+ const address = viemAccount.address.toLowerCase();
94
+ const account = {
95
+ localAccount: {
96
+ address,
97
+ index,
98
+ key,
99
+ },
100
+ signer: {
101
+ mechanismUsed: mechanism,
102
+ // A FABRICATED user, and deliberately so: there is no account at any service behind
103
+ // this one. `orgId: 'mnemonic'` is the clearest available statement of that.
104
+ user: {
105
+ address,
106
+ orgId: 'mnemonic',
107
+ userId: `${index}@mnemonic.id`,
108
+ email: `${index}@mnemonic.id`,
109
+ },
110
+ },
111
+ accountType: settings.accountGenerator.type,
112
+ };
113
+ store.set({
114
+ step: 'SignedIn',
115
+ mechanism,
116
+ account,
117
+ requireOriginApproval: originApprovalRequired(settings),
118
+ });
119
+ }
120
+ async function provideMnemonicIndex(index) {
121
+ const currentState = store.get();
122
+ if (currentState.step !== 'MnemonicIndexToProvide') {
123
+ throw new Error('no mnemonic index to provide');
124
+ }
125
+ await connect({ type: 'mnemonic', mnemonic: currentState.mechanism.mnemonic, index });
126
+ }
127
+ // The three below exist because `AuthProvider` asks for them, and they throw because this
128
+ // provider genuinely cannot answer them. Narrowing the interface so a provider only declares the
129
+ // mechanisms it implements is the honest fix and touches every consumer; it is parked until
130
+ // there is a second local mechanism to justify it.
131
+ async function provideEmail(_email) {
132
+ throw notLocal('email sign-in');
133
+ }
134
+ async function provideOTP(_otp) {
135
+ throw notLocal('an email OTP');
136
+ }
137
+ async function confirmOAuth(_mechanism, _searchParams, _redirection) {
138
+ throw notLocal('an OAuth callback');
139
+ }
140
+ return {
141
+ subscribe: store.subscribe,
142
+ init,
143
+ connect,
144
+ provideEmail,
145
+ provideOTP,
146
+ provideMnemonicIndex,
147
+ confirmOAuth,
148
+ };
149
+ }
150
+ //# sourceMappingURL=local-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-provider.js","sourceRoot":"","sources":["../src/local-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAC,iBAAiB,E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: `0x${string}`;
113
113
  publicKey: `0x${string}`;
114
114
  privateKey: `0x${string}`;
115
- mnemonicKey: `0x${string}`;
116
115
  };
117
116
  metadata: {
118
117
  email?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,IAAI;IAC7D,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC;IAEd,QAAQ,EAAE;QAAC,EAAE,EAAE,MAAM,CAAA;KAAC,GAAG,CAAC,EAAE,GAAG;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CACrD,GAAG,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAC,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AAE3C,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,IAAI;IAC1D,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,cAAc,GAAG,iBAAiB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAIxH;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC3C,IAAI,EAAE,cA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AAM,WAAW,GAAG;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAC,CAAC;AAEpF,MAAM,WAAW,YAAa,SAAQ,QAAQ,CAAC,SAAS,CAAC;IACxD,IAAI,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherplay/connect-core",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "core functionality for @etherplay/connect and other",
5
5
  "homepage": "https://github.com/wighawag/etherplay-connect#readme",
6
6
  "repository": {
@@ -17,6 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "type": "module",
20
+ "sideEffects": false,
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./dist/index.d.ts",
package/src/access.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {allowlistLookup, type AllowlistLookup, type DelegationTarget} from './permissions.js';
2
+ import type {OriginApprovalRequest, PermissionRequest} from './types.js';
2
3
 
3
4
  /**
4
5
  * WHO MAY ASK FOR AN ACCOUNT THAT IS NOT THEIRS.
@@ -224,6 +225,113 @@ export function confirmationsRequired(decision: AccessDecision): number {
224
225
  return requiresSecondConfirmation(decision) ? 2 : 1;
225
226
  }
226
227
 
228
+ /**
229
+ * THE TWO ORIGINS OF ONE SIGN-IN, AND WHAT THE APP ASKED FOR, AS ONE VALUE.
230
+ *
231
+ * They travel together everywhere: into a provider, into the approval gate, into the access
232
+ * decision, and into delivery. Named as one thing because they are two strings of the same type
233
+ * meaning OPPOSITE sides of the same question - who is asking, and whose account is at stake - and
234
+ * as positional arguments they are silently swappable. Swapping them does not fail: it produces a
235
+ * host that decides access for the wrong pair and hands the result to the wrong window.
236
+ */
237
+ export type OriginContext = {
238
+ /** the origin that opened the window, as it claimed to be */
239
+ windowOrigin: string;
240
+ /** the origin being signed for */
241
+ signingOrigin: string;
242
+ /** what the app declared at connect time; empty or absent when it asked for nothing */
243
+ permissions?: PermissionRequest[];
244
+ };
245
+
246
+ /**
247
+ * What has to be settled before a result may be handed to the opener.
248
+ *
249
+ * PROVIDER-AGNOSTIC, and here rather than in a provider because every provider needs the SAME
250
+ * answer. When it lived in one provider the three sign-in paths disagreed: the mnemonic one raised
251
+ * the access gate and the email and oauth ones passed `false`, so signing in by email skipped an
252
+ * approval that signing in by mnemonic required. A gate that only some doors have is not a gate.
253
+ *
254
+ * `false` only when there is nothing at all to settle. Anything else and the UI must ask, and the
255
+ * host must withhold the result until it has.
256
+ */
257
+ export function originApprovalRequired(request: OriginContext): false | OriginApprovalRequest {
258
+ const permissions = request.permissions || [];
259
+ // The SAME comparison the access decision uses, rather than a `!==` written again here. This does
260
+ // not decide access; all it does is notice there is nothing at all to settle, and it must not
261
+ // reach that conclusion by a rule stricter or looser than the one that would have decided the
262
+ // request.
263
+ const sameOrigin = normalizeOrigin(request.windowOrigin) === normalizeOrigin(request.signingOrigin);
264
+ if (sameOrigin && permissions.length === 0) {
265
+ return false;
266
+ }
267
+ return {
268
+ windowOrigin: request.windowOrigin,
269
+ signingOrigin: request.signingOrigin,
270
+ permissions,
271
+ };
272
+ }
273
+
274
+ /** Loopback names that are the same machine and NOT the same origin, which is the whole trap. */
275
+ const LOOPBACK_ALIASES = ['localhost', '127.0.0.1', '[::1]'];
276
+
277
+ /**
278
+ * THE MISMATCH THAT COSTS AN AFTERNOON, described so a host can say it out loud.
279
+ *
280
+ * The host posts its result with `postMessage(..., {targetOrigin: windowOrigin})`, where
281
+ * `windowOrigin` is what the opener CLAIMED to be. That origin lock is load-bearing and must not be
282
+ * relaxed: it is the whole reason a page that lies about its origin gains nothing, because the
283
+ * browser then delivers the account only to a window actually at the claimed origin.
284
+ *
285
+ * The cost of that guarantee is a failure mode with no error anywhere. If the claim is not the
286
+ * opener's real origin - `http://127.0.0.1:5173` against `http://localhost:5173`, http against
287
+ * https, or the wrong port - the sign-in completes visibly in the popup and the browser silently
288
+ * drops the result. The app waits forever and nothing on either side says why.
289
+ *
290
+ * Here rather than in the host, and pure, because it is a comparison of two origin strings by the
291
+ * same spelling rules as everything else in this file, and because a comparison a host writes for
292
+ * itself is one nobody tests. `undefined` when they agree, or when there is nothing to compare
293
+ * against: absence of a real origin means CANNOT TELL, never MISMATCH.
294
+ */
295
+ export function describeOriginMismatch(
296
+ claimed: string | undefined | null,
297
+ opener: string | undefined | null,
298
+ ): {message: string; brief: string} | undefined {
299
+ if (!claimed || !opener) {
300
+ return undefined;
301
+ }
302
+ let claimedOrigin: string;
303
+ let openerOrigin: string;
304
+ try {
305
+ claimedOrigin = new URL(normalizeOrigin(claimed)).origin;
306
+ openerOrigin = new URL(normalizeOrigin(opener)).origin;
307
+ } catch {
308
+ return undefined;
309
+ }
310
+ if (claimedOrigin === openerOrigin) {
311
+ return undefined;
312
+ }
313
+
314
+ const claimedHost = new URL(claimedOrigin).hostname;
315
+ const openerHost = new URL(openerOrigin).hostname;
316
+ // DIFFERENT loopback spellings. Same spelling on a different scheme or port is a mismatch too,
317
+ // but saying `"localhost" and "localhost" are not interchangeable` about it would be nonsense,
318
+ // and a message that is nonsense in one case is a message people stop reading in every case.
319
+ const bothLoopback =
320
+ claimedHost !== openerHost && LOOPBACK_ALIASES.includes(claimedHost) && LOOPBACK_ALIASES.includes(openerHost);
321
+
322
+ return {
323
+ brief: `[etherplay] delivering to "${claimedOrigin}", which is not where the opener is ("${openerOrigin}"): the browser will drop this.`,
324
+ message:
325
+ `[etherplay] ORIGIN MISMATCH: the page that opened this window declared "${claimedOrigin}" but is actually at ` +
326
+ `"${openerOrigin}". The result is delivered with that declared origin as postMessage's targetOrigin, so the ` +
327
+ `browser will drop it and the app will receive NOTHING, with no error of its own.` +
328
+ (bothLoopback
329
+ ? ` These two are the same machine and different origins: "${claimedHost}" and "${openerHost}" are not ` +
330
+ `interchangeable here. Open your app on "${openerHost}" or configure it to use the other, but use one.`
331
+ : ` Whatever the app passes as its origin must be exactly the origin it is served from.`),
332
+ };
333
+ }
334
+
227
335
  /**
228
336
  * Which (chain, contract) pairs may be signed with NOBODY IN THE LOOP, given how access was decided.
229
337
  *
package/src/index.ts CHANGED
@@ -122,7 +122,6 @@ export async function deriveOriginAccount(
122
122
  publicKey: originAccount.publicKey,
123
123
  address: originAccount.address,
124
124
  privateKey: originAccount.privateKey,
125
- mnemonicKey: originKey,
126
125
  },
127
126
  metadata: {},
128
127
  mechanismUsed: account.signer.mechanismUsed,
@@ -191,3 +190,4 @@ export * from './crypto.js';
191
190
  export * from './permissions.js';
192
191
  export * from './access.js';
193
192
  export * from './oauth-callback.js';
193
+ export * from './local-provider.js';
@@ -0,0 +1,185 @@
1
+ /**
2
+ * AN ACCOUNT WHOSE KEY COMES FROM THIS BROWSER AND NO SERVICE.
3
+ *
4
+ * Named `local` rather than `mnemonic` because what defines it is the ABSENCE of a service, not the
5
+ * mechanism: a raw private key, or a key from hardware, would belong here too. Today it implements
6
+ * exactly one mechanism.
7
+ *
8
+ * It used to be a branch inside `@etherplay/openfort`, where it touched `openfortInstance` nowhere
9
+ * and needed neither a publishable key nor a network. Living there meant a vendor SDK was
10
+ * constructed on a path that never called it, so a vendor version bump could break a sign-in that
11
+ * does not involve the vendor, and the failure would have looked like an application bug.
12
+ *
13
+ * WHY IN connect-core AND NOT A PACKAGE OF ITS OWN. Everything this file needs - the derivation, the
14
+ * mechanism types, the approval question - is already here, and a separate package would be one
15
+ * more version to keep in lockstep with this one. When the two drift, a tree ends up with two
16
+ * copies of the derivation resolved at two versions, which is the exact failure `@etherplay/delegation`
17
+ * was created to end. `@etherplay/openfort` is a separate package because it drags a vendor SDK;
18
+ * this drags nothing.
19
+ *
20
+ * An app that only uses `@etherplay/connect` never references it, and this package declares
21
+ * `"sideEffects": false`, which is what lets a bundler drop it rather than merely permitting it to
22
+ * in principle. Nothing here runs at import time.
23
+ */
24
+ import {mnemonicToEntropy} from '@scure/bip39';
25
+ import {wordlist} from '@scure/bip39/wordlists/english';
26
+ import {bytesToHex} from '@noble/hashes/utils';
27
+ import type {AccountGenerator} from '@etherplay/wallet-connector';
28
+ import {originApprovalRequired, type OriginContext} from './access.js';
29
+ import type {
30
+ AuthMechanism,
31
+ AuthProvider,
32
+ AuthProviderSettings,
33
+ AuthState,
34
+ EtherplayAccount,
35
+ OauthMechanism,
36
+ Redirection,
37
+ } from './types.js';
38
+
39
+ // The origins and the declared permissions come as ONE value, so the two same-typed origin strings
40
+ // cannot be swapped on the way in. This provider decides none of it; it carries the permissions into
41
+ // `AuthState` so the UI can ask, and the origins into the approval gate.
42
+ export type LocalProviderSettings = OriginContext & {
43
+ accountGenerator: AccountGenerator;
44
+ };
45
+
46
+ /**
47
+ * The smallest store that satisfies the contract `AuthProvider` extends.
48
+ *
49
+ * Written here rather than depended on, because it is fifteen lines and this package deliberately
50
+ * has no store library, no framework and no browser globals in its dependency list.
51
+ */
52
+ function createStateStore(initial: AuthState) {
53
+ let current = initial;
54
+ const subscribers = new Set<(state: AuthState) => void>();
55
+ return {
56
+ subscribe(run: (state: AuthState) => void): () => void {
57
+ subscribers.add(run);
58
+ // Called immediately with the current value: the store contract every Svelte consumer,
59
+ // including `$authProvider` in the host, relies on.
60
+ run(current);
61
+ return () => {
62
+ subscribers.delete(run);
63
+ };
64
+ },
65
+ set(state: AuthState) {
66
+ current = state;
67
+ for (const run of [...subscribers]) {
68
+ run(current);
69
+ }
70
+ },
71
+ get(): AuthState {
72
+ return current;
73
+ },
74
+ };
75
+ }
76
+
77
+ /** Said the same way by every method that cannot do its job here, so the reason is never a guess. */
78
+ function notLocal(what: string): Error {
79
+ return new Error(
80
+ `${what} is hosted authentication and the local provider has no host: it derives the account from a mnemonic in this browser. ` +
81
+ `Route this mechanism to a hosted provider (the host does this by mechanism, not by the "provider" query parameter).`,
82
+ );
83
+ }
84
+
85
+ export function createLocalProvider(settings: LocalProviderSettings): AuthProvider {
86
+ const store = createStateStore({step: 'Idle'} as AuthState);
87
+
88
+ /**
89
+ * Nothing to initialise, and that is the property worth keeping.
90
+ *
91
+ * No key, no SDK, no network: a mnemonic sign-in completes in a host built with no vendor
92
+ * credentials at all, offline, over plain http. The two steps are still emitted so the host's
93
+ * UI sees the same sequence it sees from a hosted provider.
94
+ */
95
+ async function init(_providerSettings?: AuthProviderSettings): Promise<void> {
96
+ store.set({step: 'Initialising', auto: true});
97
+ store.set({step: 'Initialised'});
98
+ }
99
+
100
+ async function connect(mechanism: AuthMechanism, _redirection?: Redirection): Promise<void> {
101
+ if (mechanism.type !== 'mnemonic') {
102
+ throw notLocal(`"${mechanism.type}"`);
103
+ }
104
+
105
+ if (mechanism.index === undefined) {
106
+ store.set({
107
+ step: 'MnemonicIndexToProvide',
108
+ mechanism: {type: 'mnemonic', mnemonic: mechanism.mnemonic, index: undefined},
109
+ });
110
+ return;
111
+ }
112
+
113
+ store.set({step: 'GeneratingAccount', mechanism});
114
+
115
+ const mnemonic = mechanism.mnemonic;
116
+ const index = mechanism.index ?? 0;
117
+
118
+ const viemAccount = settings.accountGenerator.fromMnemonicToAccount(mnemonic, index);
119
+ const keyUint8Array = mnemonicToEntropy(mnemonic, wordlist);
120
+ const key = `0x${bytesToHex(keyUint8Array)}` as `0x${string}`;
121
+ const address = viemAccount.address.toLowerCase() as `0x${string}`;
122
+ const account: EtherplayAccount = {
123
+ localAccount: {
124
+ address,
125
+ index,
126
+ key,
127
+ },
128
+ signer: {
129
+ mechanismUsed: mechanism,
130
+ // A FABRICATED user, and deliberately so: there is no account at any service behind
131
+ // this one. `orgId: 'mnemonic'` is the clearest available statement of that.
132
+ user: {
133
+ address,
134
+ orgId: 'mnemonic',
135
+ userId: `${index}@mnemonic.id`,
136
+ email: `${index}@mnemonic.id`,
137
+ },
138
+ },
139
+ accountType: settings.accountGenerator.type,
140
+ };
141
+
142
+ store.set({
143
+ step: 'SignedIn',
144
+ mechanism,
145
+ account,
146
+ requireOriginApproval: originApprovalRequired(settings),
147
+ });
148
+ }
149
+
150
+ async function provideMnemonicIndex(index: number): Promise<void> {
151
+ const currentState = store.get();
152
+ if (currentState.step !== 'MnemonicIndexToProvide') {
153
+ throw new Error('no mnemonic index to provide');
154
+ }
155
+ await connect({type: 'mnemonic', mnemonic: currentState.mechanism.mnemonic, index});
156
+ }
157
+
158
+ // The three below exist because `AuthProvider` asks for them, and they throw because this
159
+ // provider genuinely cannot answer them. Narrowing the interface so a provider only declares the
160
+ // mechanisms it implements is the honest fix and touches every consumer; it is parked until
161
+ // there is a second local mechanism to justify it.
162
+ async function provideEmail(_email: string): Promise<void> {
163
+ throw notLocal('email sign-in');
164
+ }
165
+ async function provideOTP(_otp: string): Promise<void> {
166
+ throw notLocal('an email OTP');
167
+ }
168
+ async function confirmOAuth(
169
+ _mechanism: OauthMechanism,
170
+ _searchParams: URLSearchParams,
171
+ _redirection: Redirection,
172
+ ): Promise<void> {
173
+ throw notLocal('an OAuth callback');
174
+ }
175
+
176
+ return {
177
+ subscribe: store.subscribe,
178
+ init,
179
+ connect,
180
+ provideEmail,
181
+ provideOTP,
182
+ provideMnemonicIndex,
183
+ confirmOAuth,
184
+ };
185
+ }
package/src/types.ts CHANGED
@@ -123,8 +123,11 @@ export type OriginAccount = {
123
123
  origin: string;
124
124
  address: `0x${string}`;
125
125
  publicKey: `0x${string}`;
126
+ // No entropy/mnemonic key here on purpose: the origin signer's own private key is the least
127
+ // that has to be held to sign for this origin, whereas the entropy it was derived from would
128
+ // reconstruct every key this origin could ever derive. Since this object is persisted, keeping
129
+ // it would put that seed at rest in the app's storage for nothing: nothing reads it.
126
130
  privateKey: `0x${string}`;
127
- mnemonicKey: `0x${string}`;
128
131
  };
129
132
  metadata: {
130
133
  email?: string;