@cartridge/controller 0.11.3 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartridge/controller",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "description": "Cartridge Controller",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "vite-plugin-node-polyfills": "^0.23.0",
51
51
  "vite-plugin-top-level-await": "^1.4.4",
52
52
  "vite-plugin-wasm": "^3.4.1",
53
- "@cartridge/tsconfig": "0.11.3"
53
+ "@cartridge/tsconfig": "0.12.0"
54
54
  },
55
55
  "scripts": {
56
56
  "build:deps": "pnpm build",
package/src/controller.ts CHANGED
@@ -14,6 +14,7 @@ import { NotReadyToConnect } from "./errors";
14
14
  import { KeychainIFrame } from "./iframe";
15
15
  import BaseProvider from "./provider";
16
16
  import {
17
+ AuthOptions,
17
18
  Chain,
18
19
  ConnectError,
19
20
  ConnectReply,
@@ -224,7 +225,9 @@ export default class ControllerProvider extends BaseProvider {
224
225
  return this.account;
225
226
  }
226
227
 
227
- async connect(): Promise<WalletAccount | undefined> {
228
+ async connect(
229
+ signupOptions?: AuthOptions,
230
+ ): Promise<WalletAccount | undefined> {
228
231
  if (!this.iframes) {
229
232
  return;
230
233
  }
@@ -248,7 +251,9 @@ export default class ControllerProvider extends BaseProvider {
248
251
  this.iframes.keychain.open();
249
252
 
250
253
  try {
251
- let response = await this.keychain.connect(this.options.signupOptions);
254
+ // Use connect() parameter if provided, otherwise fall back to constructor options
255
+ const effectiveOptions = signupOptions ?? this.options.signupOptions;
256
+ let response = await this.keychain.connect(effectiveOptions);
252
257
  if (response.code !== ResponseCodes.SUCCESS) {
253
258
  throw new Error(response.message);
254
259
  }
@@ -33,11 +33,16 @@ export class KeychainIFrame extends IFrame<Keychain> {
33
33
  username,
34
34
  onSessionCreated,
35
35
  encryptedBlob,
36
+ propagateSessionErrors,
36
37
  ...iframeOptions
37
38
  }: KeychainIframeOptions) {
38
39
  const _url = new URL(url ?? KEYCHAIN_URL);
39
40
  const walletBridge = new WalletBridge();
40
41
 
42
+ if (propagateSessionErrors) {
43
+ _url.searchParams.set("propagate_error", "true");
44
+ }
45
+
41
46
  if (version) {
42
47
  _url.searchParams.set("v", encodeURIComponent(version));
43
48
  }