@openfort/openfort-js 0.7.2 → 0.7.4

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/index.cjs CHANGED
@@ -4,10 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var hash = require('@ethersproject/hash');
6
6
  var globalAxios = require('axios');
7
+ var providers = require('@ethersproject/providers');
8
+ var bytes = require('@ethersproject/bytes');
9
+ var events = require('events');
10
+ var uuid = require('uuid');
7
11
  var jose = require('jose');
8
12
  var secp256k1 = require('@noble/curves/secp256k1');
9
13
  var signingKey = require('@ethersproject/signing-key');
10
- var bytes = require('@ethersproject/bytes');
11
14
  var transactions = require('@ethersproject/transactions');
12
15
 
13
16
  exports.EmbeddedState = void 0;
@@ -18,6 +21,10 @@ exports.EmbeddedState = void 0;
18
21
  EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
19
22
  EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
20
23
  })(exports.EmbeddedState || (exports.EmbeddedState = {}));
24
+ var OpenfortEvents;
25
+ (function (OpenfortEvents) {
26
+ OpenfortEvents["LOGGED_OUT"] = "loggedOut";
27
+ })(OpenfortEvents || (OpenfortEvents = {}));
21
28
  var AccountType;
22
29
  (function (AccountType) {
23
30
  AccountType["UPGRADEABLE_V4"] = "Upgradeable_v04";
@@ -52,6 +59,7 @@ exports.OAuthProvider = void 0;
52
59
  (function (OAuthProvider) {
53
60
  OAuthProvider["GOOGLE"] = "google";
54
61
  OAuthProvider["TWITTER"] = "twitter";
62
+ OAuthProvider["FACEBOOK"] = "facebook";
55
63
  })(exports.OAuthProvider || (exports.OAuthProvider = {}));
56
64
 
57
65
  /* tslint:disable */
@@ -3049,6 +3057,1446 @@ class SDKConfiguration {
3049
3057
  }
3050
3058
  }
3051
3059
 
3060
+ const chain$m = {
3061
+ chain: 'BSC',
3062
+ chainId: 56,
3063
+ explorers: [
3064
+ {
3065
+ name: 'bscscan',
3066
+ url: 'https://bscscan.com',
3067
+ standard: 'EIP3091',
3068
+ },
3069
+ {
3070
+ name: 'dexguru',
3071
+ url: 'https://bnb.dex.guru',
3072
+ standard: 'EIP3091',
3073
+ icon: {
3074
+ url: 'ipfs://QmRaASKRSjQ5btoUQ2rNTJNxKtx2a2RoewgA7DMQkLVEne',
3075
+ width: 83,
3076
+ height: 82,
3077
+ format: 'svg',
3078
+ },
3079
+ },
3080
+ ],
3081
+ faucets: [],
3082
+ features: [],
3083
+ icon: {
3084
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/binance-coin/512.png',
3085
+ width: 512,
3086
+ height: 512,
3087
+ format: 'png',
3088
+ },
3089
+ infoURL: 'https://www.bnbchain.org/en',
3090
+ name: 'BNB Smart Chain Mainnet',
3091
+ nativeCurrency: {
3092
+ name: 'BNB Chain Native Token',
3093
+ symbol: 'BNB',
3094
+ decimals: 18,
3095
+ },
3096
+ networkId: 56,
3097
+ redFlags: [],
3098
+ rpc: [
3099
+ 'https://bsc.publicnode.com',
3100
+ 'https://bsc-dataseed1.bnbchain.org',
3101
+ 'https://bsc-dataseed2.bnbchain.org',
3102
+ 'https://bsc-dataseed3.bnbchain.org',
3103
+ 'https://bsc-dataseed4.bnbchain.org',
3104
+ 'https://bsc-dataseed1.defibit.io',
3105
+ 'https://bsc-dataseed2.defibit.io',
3106
+ 'https://bsc-dataseed3.defibit.io',
3107
+ 'https://bsc-dataseed4.defibit.io',
3108
+ 'https://bsc-dataseed1.ninicoin.io',
3109
+ 'https://bsc-dataseed2.ninicoin.io',
3110
+ 'https://bsc-dataseed3.ninicoin.io',
3111
+ 'https://bsc-dataseed4.ninicoin.io',
3112
+ 'wss://bsc.publicnode.com',
3113
+ 'wss://bsc-ws-node.nariox.org',
3114
+ ],
3115
+ shortName: 'bnb',
3116
+ slip44: 714,
3117
+ slug: 'binance',
3118
+ testnet: false,
3119
+ };
3120
+
3121
+ const chain$l = {
3122
+ chain: 'BSC',
3123
+ chainId: 97,
3124
+ explorers: [
3125
+ {
3126
+ name: 'bscscan-testnet',
3127
+ url: 'https://testnet.bscscan.com',
3128
+ standard: 'EIP3091',
3129
+ },
3130
+ ],
3131
+ faucets: ['https://testnet.bnbchain.org/faucet-smart'],
3132
+ features: [],
3133
+ icon: {
3134
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/binance-coin/512.png',
3135
+ width: 512,
3136
+ height: 512,
3137
+ format: 'png',
3138
+ },
3139
+ infoURL: 'https://www.bnbchain.org/en',
3140
+ name: 'BNB Smart Chain Testnet',
3141
+ nativeCurrency: {
3142
+ name: 'BNB Chain Native Token',
3143
+ symbol: 'tBNB',
3144
+ decimals: 18,
3145
+ },
3146
+ networkId: 97,
3147
+ redFlags: [],
3148
+ rpc: [
3149
+ 'https://bsc-testnet.publicnode.com',
3150
+ 'https://data-seed-prebsc-1-s1.bnbchain.org:8545',
3151
+ 'https://data-seed-prebsc-2-s1.bnbchain.org:8545',
3152
+ 'https://data-seed-prebsc-1-s2.bnbchain.org:8545',
3153
+ 'https://data-seed-prebsc-2-s2.bnbchain.org:8545',
3154
+ 'https://data-seed-prebsc-1-s3.bnbchain.org:8545',
3155
+ 'https://data-seed-prebsc-2-s3.bnbchain.org:8545',
3156
+ ],
3157
+ shortName: 'bnbt',
3158
+ slug: 'binance-testnet',
3159
+ testnet: true,
3160
+ };
3161
+
3162
+ const chain$k = {
3163
+ name: 'Base',
3164
+ chain: 'ETH',
3165
+ rpc: [
3166
+ 'https://mainnet.base.org',
3167
+ ],
3168
+ faucets: [],
3169
+ nativeCurrency: {
3170
+ name: 'Ether',
3171
+ symbol: 'ETH',
3172
+ decimals: 18,
3173
+ },
3174
+ infoURL: 'https://base.org',
3175
+ shortName: 'base',
3176
+ chainId: 8453,
3177
+ networkId: 8453,
3178
+ icon: {
3179
+ url: 'ipfs://QmW5Vn15HeRkScMfPcW12ZdZcC2yUASpu6eCsECRdEmjjj/base-512.png',
3180
+ height: 512,
3181
+ width: 512,
3182
+ format: 'png',
3183
+ },
3184
+ explorers: [
3185
+ {
3186
+ name: 'basescout',
3187
+ url: 'https://base.blockscout.com',
3188
+ icon: {
3189
+ url: 'ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM',
3190
+ width: 551,
3191
+ height: 540,
3192
+ format: 'png',
3193
+ },
3194
+ standard: 'EIP3091',
3195
+ },
3196
+ {
3197
+ name: 'basescan',
3198
+ url: 'https://basescan.org',
3199
+ standard: 'none',
3200
+ },
3201
+ ],
3202
+ status: 'active',
3203
+ testnet: false,
3204
+ slug: 'base',
3205
+ };
3206
+
3207
+ const chain$j = {
3208
+ chain: 'ETH',
3209
+ chainId: 84532,
3210
+ explorers: [
3211
+ {
3212
+ name: 'basescout',
3213
+ url: 'https://base-sepolia.blockscout.com',
3214
+ standard: 'EIP3091',
3215
+ icon: {
3216
+ url: 'ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM',
3217
+ width: 551,
3218
+ height: 540,
3219
+ format: 'png',
3220
+ },
3221
+ },
3222
+ ],
3223
+ faucets: [],
3224
+ icon: {
3225
+ url: 'ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv',
3226
+ width: 1200,
3227
+ height: 1200,
3228
+ format: 'png',
3229
+ },
3230
+ infoURL: 'https://base.org',
3231
+ name: 'Base Sepolia Testnet',
3232
+ nativeCurrency: {
3233
+ name: 'Sepolia Ether',
3234
+ symbol: 'ETH',
3235
+ decimals: 18,
3236
+ },
3237
+ networkId: 84532,
3238
+ rpc: [
3239
+ 'https://sepolia.base.org',
3240
+ ],
3241
+ shortName: 'basesep',
3242
+ slug: 'base-sepolia-testnet',
3243
+ testnet: true,
3244
+ };
3245
+
3246
+ const chain$i = {
3247
+ name: 'Beam',
3248
+ chainId: 4337,
3249
+ chain: 'BEAM',
3250
+ shortName: 'Beam',
3251
+ slug: 'beam',
3252
+ icon: {
3253
+ url: 'ipfs://QmQJ21NWyGGDraicVEzS1Uqq1yXahM9NCuNZgnfYvtspdt',
3254
+ height: 512,
3255
+ width: 512,
3256
+ format: 'png',
3257
+ },
3258
+ features: [
3259
+ {
3260
+ name: 'EIP1559',
3261
+ },
3262
+ ],
3263
+ nativeCurrency: {
3264
+ name: 'Beam',
3265
+ symbol: 'BEAM',
3266
+ decimals: 18,
3267
+ },
3268
+ rpc: [
3269
+ 'https://eu.build.onbeam.com/rpc/14bfbcc5-49c1-40e8-82c2-025c9a1834e1',
3270
+ ],
3271
+ faucets: ['https://faucet.onbeam.com'],
3272
+ explorers: [
3273
+ {
3274
+ name: 'Beam Explorer',
3275
+ url: 'https://subnets.avax.network/beam/',
3276
+ standard: 'EIP3091',
3277
+ },
3278
+ ],
3279
+ infoURL: 'https://gaming.meritcircle.io/',
3280
+ testnet: false,
3281
+ };
3282
+
3283
+ const chain$h = {
3284
+ name: 'Beam Testnet',
3285
+ chainId: 13337,
3286
+ chain: 'BEAM',
3287
+ shortName: 'Beam Testnet',
3288
+ slug: 'beam-testnet',
3289
+ features: [
3290
+ {
3291
+ name: 'EIP1559',
3292
+ },
3293
+ ],
3294
+ icon: {
3295
+ url: 'ipfs://QmQJ21NWyGGDraicVEzS1Uqq1yXahM9NCuNZgnfYvtspdt',
3296
+ height: 512,
3297
+ width: 512,
3298
+ format: 'png',
3299
+ },
3300
+ nativeCurrency: {
3301
+ name: 'Beam',
3302
+ symbol: 'BEAM',
3303
+ decimals: 18,
3304
+ },
3305
+ rpc: [
3306
+ 'https://eu.build.onbeam.com/rpc/testnet/14bfbcc5-49c1-40e8-82c2-025c9a1834e1',
3307
+ ],
3308
+ faucets: ['https://faucet.avax.network/?subnet=beam', 'https://faucet.onbeam.com'],
3309
+ explorers: [
3310
+ {
3311
+ name: 'Beam Explorer',
3312
+ url: 'https://subnets-test.avax.network/beam',
3313
+ standard: 'EIP3091',
3314
+ },
3315
+ ],
3316
+ infoURL: 'https://www.onbeam.com',
3317
+ testnet: true,
3318
+ };
3319
+
3320
+ const chain$g = {
3321
+ chain: 'AVAX',
3322
+ chainId: 43113,
3323
+ explorers: [
3324
+ {
3325
+ name: 'snowtrace',
3326
+ url: 'https://testnet.snowtrace.io',
3327
+ standard: 'EIP3091',
3328
+ },
3329
+ ],
3330
+ faucets: ['https://faucet.avax-test.network/'],
3331
+ features: [],
3332
+ icon: {
3333
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/avalanche/512.png',
3334
+ width: 512,
3335
+ height: 512,
3336
+ format: 'png',
3337
+ },
3338
+ infoURL: 'https://cchain.explorer.avax-test.network',
3339
+ name: 'Avalanche Fuji Testnet',
3340
+ nativeCurrency: {
3341
+ name: 'Avalanche',
3342
+ symbol: 'AVAX',
3343
+ decimals: 18,
3344
+ },
3345
+ networkId: 43113,
3346
+ redFlags: [],
3347
+ rpc: [
3348
+ 'https://api.avax-test.network/ext/bc/C/rpc',
3349
+ 'https://avalanche-fuji-c-chain.publicnode.com',
3350
+ ],
3351
+ shortName: 'Fuji',
3352
+ slug: 'avalanche-fuji',
3353
+ testnet: true,
3354
+ };
3355
+
3356
+ const chain$f = {
3357
+ chain: 'AVAX',
3358
+ chainId: 43114,
3359
+ explorers: [
3360
+ {
3361
+ name: 'snowtrace',
3362
+ url: 'https://snowtrace.io',
3363
+ standard: 'EIP3091',
3364
+ },
3365
+ ],
3366
+ faucets: [],
3367
+ features: [
3368
+ {
3369
+ name: 'EIP1559',
3370
+ },
3371
+ ],
3372
+ icon: {
3373
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/avalanche/512.png',
3374
+ width: 512,
3375
+ height: 512,
3376
+ format: 'png',
3377
+ },
3378
+ infoURL: 'https://www.avax.network/',
3379
+ name: 'Avalanche C-Chain',
3380
+ nativeCurrency: {
3381
+ name: 'Avalanche',
3382
+ symbol: 'AVAX',
3383
+ decimals: 18,
3384
+ },
3385
+ networkId: 43114,
3386
+ redFlags: [],
3387
+ rpc: [
3388
+ 'https://api.avax.network/ext/bc/C/rpc',
3389
+ 'https://avalanche-c-chain.publicnode.com',
3390
+ ],
3391
+ shortName: 'avax',
3392
+ slip44: 9005,
3393
+ slug: 'avalanche',
3394
+ testnet: false,
3395
+ };
3396
+
3397
+ const chain$e = {
3398
+ chain: 'ETH',
3399
+ chainId: 11155111,
3400
+ explorers: [
3401
+ {
3402
+ name: 'etherscan-sepolia',
3403
+ url: 'https://sepolia.etherscan.io',
3404
+ standard: 'EIP3091',
3405
+ },
3406
+ {
3407
+ name: 'otterscan-sepolia',
3408
+ url: 'https://sepolia.otterscan.io',
3409
+ standard: 'EIP3091',
3410
+ },
3411
+ ],
3412
+ faucets: ['http://fauceth.komputing.org?chain=11155111'],
3413
+ features: [],
3414
+ icon: {
3415
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/ethereum/512.png',
3416
+ width: 512,
3417
+ height: 512,
3418
+ format: 'png',
3419
+ },
3420
+ infoURL: 'https://sepolia.otterscan.io',
3421
+ name: 'Sepolia',
3422
+ nativeCurrency: {
3423
+ name: 'Sepolia Ether',
3424
+ symbol: 'ETH',
3425
+ decimals: 18,
3426
+ },
3427
+ networkId: 11155111,
3428
+ redFlags: [],
3429
+ rpc: [
3430
+ 'https://rpc.sepolia.org',
3431
+ 'https://rpc2.sepolia.org',
3432
+ 'https://rpc-sepolia.rockx.com',
3433
+ 'https://rpc.sepolia.ethpandaops.io',
3434
+ 'https://sepolia.gateway.tenderly.co',
3435
+ 'https://ethereum-sepolia.publicnode.com',
3436
+ ],
3437
+ shortName: 'sep',
3438
+ slug: 'sepolia',
3439
+ testnet: true,
3440
+ title: 'Ethereum Testnet Sepolia',
3441
+ };
3442
+
3443
+ const chain$d = {
3444
+ chain: 'ETH',
3445
+ chainId: 59140,
3446
+ explorers: [
3447
+ {
3448
+ name: 'Etherscan',
3449
+ url: 'https://goerli.lineascan.build',
3450
+ standard: 'EIP3091',
3451
+ icon: {
3452
+ url: 'ipfs://QmURjritnHL7a8TwZgsFwp3f272DJmG5paaPtWDZ98QZwH',
3453
+ width: 97,
3454
+ height: 102,
3455
+ format: 'svg',
3456
+ },
3457
+ },
3458
+ {
3459
+ name: 'Blockscout',
3460
+ url: 'https://explorer.goerli.linea.build',
3461
+ standard: 'EIP3091',
3462
+ icon: {
3463
+ url: 'ipfs://QmURjritnHL7a8TwZgsFwp3f272DJmG5paaPtWDZ98QZwH',
3464
+ width: 97,
3465
+ height: 102,
3466
+ format: 'svg',
3467
+ },
3468
+ },
3469
+ ],
3470
+ faucets: ['https://faucetlink.to/goerli'],
3471
+ icon: {
3472
+ url: 'ipfs://QmURjritnHL7a8TwZgsFwp3f272DJmG5paaPtWDZ98QZwH',
3473
+ width: 97,
3474
+ height: 102,
3475
+ format: 'svg',
3476
+ },
3477
+ infoURL: 'https://linea.build',
3478
+ name: 'Linea Testnet',
3479
+ nativeCurrency: {
3480
+ name: 'Linea Ether',
3481
+ symbol: 'ETH',
3482
+ decimals: 18,
3483
+ },
3484
+ networkId: 59140,
3485
+ parent: {
3486
+ type: 'L2',
3487
+ chain: 'eip155-5',
3488
+ bridges: [
3489
+ {
3490
+ url: 'https://goerli.hop.exchange/#/send?token=ETH&sourceNetwork=ethereum&destNetwork=linea',
3491
+ },
3492
+ ],
3493
+ },
3494
+ rpc: [
3495
+ 'https://rpc.goerli.linea.build',
3496
+ 'wss://rpc.goerli.linea.build',
3497
+ ],
3498
+ shortName: 'linea-testnet',
3499
+ slug: 'linea-testnet',
3500
+ status: 'active',
3501
+ testnet: true,
3502
+ title: 'Linea Goerli Testnet',
3503
+ };
3504
+
3505
+ const chain$c = {
3506
+ chain: 'GNO',
3507
+ chainId: 10200,
3508
+ explorers: [
3509
+ {
3510
+ name: 'blockscout',
3511
+ url: 'https://gnosis-chiado.blockscout.com',
3512
+ standard: 'EIP3091',
3513
+ icon: {
3514
+ url: 'ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM',
3515
+ width: 551,
3516
+ height: 540,
3517
+ format: 'png',
3518
+ },
3519
+ },
3520
+ ],
3521
+ faucets: ['https://gnosisfaucet.com'],
3522
+ icon: {
3523
+ url: 'ipfs://bafybeidk4swpgdyqmpz6shd5onvpaujvwiwthrhypufnwr6xh3dausz2dm',
3524
+ width: 1800,
3525
+ height: 1800,
3526
+ format: 'png',
3527
+ },
3528
+ infoURL: 'https://docs.gnosischain.com',
3529
+ name: 'Gnosis Chiado Testnet',
3530
+ nativeCurrency: {
3531
+ name: 'Chiado xDAI',
3532
+ symbol: 'XDAI',
3533
+ decimals: 18,
3534
+ },
3535
+ networkId: 10200,
3536
+ rpc: [
3537
+ 'https://rpc.chiadochain.net',
3538
+ 'https://rpc.chiado.gnosis.gateway.fm',
3539
+ 'wss://rpc.chiadochain.net/wss',
3540
+ 'https://gnosis-chiado-rpc.publicnode.com',
3541
+ 'wss://gnosis-chiado-rpc.publicnode.com',
3542
+ 'https://gnosis-chiado.drpc.org',
3543
+ 'wss://gnosis-chiado.drpc.org',
3544
+ ],
3545
+ shortName: 'chi',
3546
+ slip44: 1,
3547
+ slug: 'gnosis-chiado-testnet',
3548
+ testnet: true,
3549
+ };
3550
+
3551
+ const chain$b = {
3552
+ chain: 'Immutable zkEVM',
3553
+ chainId: 13371,
3554
+ explorers: [
3555
+ {
3556
+ name: 'Immutable explorer',
3557
+ url: 'https://explorer.immutable.com',
3558
+ standard: 'EIP3091',
3559
+ icon: {
3560
+ url: 'ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw',
3561
+ width: 1168,
3562
+ height: 1168,
3563
+ format: 'png',
3564
+ },
3565
+ },
3566
+ ],
3567
+ faucets: ['https://docs.immutable.com/docs/zkEVM/guides/faucet'],
3568
+ icon: {
3569
+ url: 'ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw',
3570
+ width: 1168,
3571
+ height: 1168,
3572
+ format: 'png',
3573
+ },
3574
+ infoURL: 'https://www.immutable.com',
3575
+ name: 'Immutable zkEVM',
3576
+ nativeCurrency: {
3577
+ name: 'IMX',
3578
+ symbol: 'IMX',
3579
+ decimals: 18,
3580
+ },
3581
+ networkId: 13371,
3582
+ rpc: [
3583
+ 'https://rpc.immutable.com',
3584
+ 'https://immutable-zkevm.drpc.org',
3585
+ 'wss://immutable-zkevm.drpc.org',
3586
+ ],
3587
+ shortName: 'imx',
3588
+ slug: 'immutable-zkevm',
3589
+ testnet: false,
3590
+ };
3591
+
3592
+ const chain$a = {
3593
+ chain: 'ETH',
3594
+ chainId: 421614,
3595
+ explorers: [
3596
+ {
3597
+ name: 'Arbitrum Sepolia Rollup Testnet Explorer',
3598
+ url: 'https://sepolia-explorer.arbitrum.io',
3599
+ standard: 'EIP3091',
3600
+ },
3601
+ ],
3602
+ faucets: [],
3603
+ infoURL: 'https://arbitrum.io',
3604
+ name: 'Arbitrum Sepolia',
3605
+ nativeCurrency: {
3606
+ name: 'Sepolia Ether',
3607
+ symbol: 'ETH',
3608
+ decimals: 18,
3609
+ },
3610
+ networkId: 421614,
3611
+ parent: {
3612
+ type: 'L2',
3613
+ chain: 'eip155-11155111',
3614
+ bridges: [
3615
+ {
3616
+ url: 'https://bridge.arbitrum.io',
3617
+ },
3618
+ ],
3619
+ },
3620
+ rpc: [
3621
+ 'https://sepolia-rollup.arbitrum.io/rpc',
3622
+ ],
3623
+ shortName: 'arb-sep',
3624
+ slug: 'arbitrum-sepolia',
3625
+ testnet: true,
3626
+ title: 'Arbitrum Sepolia Rollup Testnet',
3627
+ };
3628
+
3629
+ const chain$9 = {
3630
+ chain: 'ETH',
3631
+ chainId: 42161,
3632
+ explorers: [
3633
+ {
3634
+ name: 'Arbiscan',
3635
+ url: 'https://arbiscan.io',
3636
+ standard: 'EIP3091',
3637
+ },
3638
+ {
3639
+ name: 'Arbitrum Explorer',
3640
+ url: 'https://explorer.arbitrum.io',
3641
+ standard: 'EIP3091',
3642
+ },
3643
+ {
3644
+ name: 'dexguru',
3645
+ url: 'https://arbitrum.dex.guru',
3646
+ standard: 'EIP3091',
3647
+ icon: {
3648
+ url: 'ipfs://QmRaASKRSjQ5btoUQ2rNTJNxKtx2a2RoewgA7DMQkLVEne',
3649
+ width: 83,
3650
+ height: 82,
3651
+ format: 'svg',
3652
+ },
3653
+ },
3654
+ ],
3655
+ faucets: [],
3656
+ features: [],
3657
+ icon: {
3658
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/arbitrum/512.png',
3659
+ width: 512,
3660
+ height: 512,
3661
+ format: 'png',
3662
+ },
3663
+ infoURL: 'https://arbitrum.io',
3664
+ name: 'Arbitrum One',
3665
+ nativeCurrency: {
3666
+ name: 'Ether',
3667
+ symbol: 'ETH',
3668
+ decimals: 18,
3669
+ },
3670
+ networkId: 42161,
3671
+ parent: {
3672
+ type: 'L2',
3673
+ chain: 'eip155-1',
3674
+ bridges: [
3675
+ {
3676
+ url: 'https://bridge.arbitrum.io',
3677
+ },
3678
+ ],
3679
+ },
3680
+ redFlags: [],
3681
+ rpc: [
3682
+ 'https://arb1.arbitrum.io/rpc',
3683
+ 'https://arbitrum-one.publicnode.com',
3684
+ 'wss://arbitrum-one.publicnode.com',
3685
+ ],
3686
+ shortName: 'arb1',
3687
+ slug: 'arbitrum',
3688
+ testnet: false,
3689
+ };
3690
+
3691
+ const chain$8 = {
3692
+ chain: 'ETH',
3693
+ chainId: 42170,
3694
+ explorers: [
3695
+ {
3696
+ name: 'Arbitrum Nova Chain Explorer',
3697
+ url: 'https://nova-explorer.arbitrum.io',
3698
+ standard: 'EIP3091',
3699
+ icon: {
3700
+ url: 'ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM',
3701
+ width: 551,
3702
+ height: 540,
3703
+ format: 'png',
3704
+ },
3705
+ },
3706
+ {
3707
+ name: 'dexguru',
3708
+ url: 'https://nova.dex.guru',
3709
+ standard: 'EIP3091',
3710
+ icon: {
3711
+ url: 'ipfs://QmRaASKRSjQ5btoUQ2rNTJNxKtx2a2RoewgA7DMQkLVEne',
3712
+ width: 83,
3713
+ height: 82,
3714
+ format: 'svg',
3715
+ },
3716
+ },
3717
+ ],
3718
+ faucets: [],
3719
+ infoURL: 'https://arbitrum.io',
3720
+ name: 'Arbitrum Nova',
3721
+ nativeCurrency: {
3722
+ name: 'Ether',
3723
+ symbol: 'ETH',
3724
+ decimals: 18,
3725
+ },
3726
+ networkId: 42170,
3727
+ parent: {
3728
+ type: 'L2',
3729
+ chain: 'eip155-1',
3730
+ bridges: [
3731
+ {
3732
+ url: 'https://bridge.arbitrum.io',
3733
+ },
3734
+ ],
3735
+ },
3736
+ rpc: [
3737
+ 'https://nova.arbitrum.io/rpc',
3738
+ 'https://arbitrum-nova.publicnode.com',
3739
+ 'wss://arbitrum-nova.publicnode.com',
3740
+ ],
3741
+ shortName: 'arb-nova',
3742
+ slug: 'arbitrum-nova',
3743
+ testnet: false,
3744
+ };
3745
+
3746
+ const chain$7 = {
3747
+ chain: 'Polygon',
3748
+ chainId: 137,
3749
+ explorers: [
3750
+ {
3751
+ name: 'polygonscan',
3752
+ url: 'https://polygonscan.com',
3753
+ standard: 'EIP3091',
3754
+ },
3755
+ {
3756
+ name: 'dexguru',
3757
+ url: 'https://polygon.dex.guru',
3758
+ standard: 'EIP3091',
3759
+ icon: {
3760
+ url: 'ipfs://QmRaASKRSjQ5btoUQ2rNTJNxKtx2a2RoewgA7DMQkLVEne',
3761
+ width: 83,
3762
+ height: 82,
3763
+ format: 'svg',
3764
+ },
3765
+ },
3766
+ ],
3767
+ faucets: [],
3768
+ features: [],
3769
+ icon: {
3770
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/polygon/512.png',
3771
+ width: 512,
3772
+ height: 512,
3773
+ format: 'png',
3774
+ },
3775
+ infoURL: 'https://polygon.technology/',
3776
+ name: 'Polygon Mainnet',
3777
+ nativeCurrency: {
3778
+ name: 'MATIC',
3779
+ symbol: 'MATIC',
3780
+ decimals: 18,
3781
+ },
3782
+ networkId: 137,
3783
+ redFlags: [],
3784
+ rpc: [
3785
+ 'https://polygon-rpc.com',
3786
+ 'https://rpc-mainnet.matic.network',
3787
+ 'https://matic-mainnet.chainstacklabs.com',
3788
+ 'https://rpc-mainnet.maticvigil.com',
3789
+ 'https://rpc-mainnet.matic.quiknode.pro',
3790
+ 'https://matic-mainnet-full-rpc.bwarelabs.com',
3791
+ 'https://polygon-bor.publicnode.com',
3792
+ 'wss://polygon-bor.publicnode.com',
3793
+ 'https://polygon.gateway.tenderly.co',
3794
+ 'wss://polygon.gateway.tenderly.co',
3795
+ ],
3796
+ shortName: 'matic',
3797
+ slip44: 966,
3798
+ slug: 'polygon',
3799
+ testnet: false,
3800
+ };
3801
+
3802
+ const chain$6 = {
3803
+ chain: 'Polygon',
3804
+ chainId: 80002,
3805
+ explorers: [
3806
+ {
3807
+ name: 'polygonamoy',
3808
+ url: 'https://www.oklink.com/amoy',
3809
+ standard: 'EIP3091',
3810
+ },
3811
+ ],
3812
+ faucets: ['https://faucet.polygon.technology/'],
3813
+ features: [],
3814
+ icon: {
3815
+ url: 'ipfs://QmcxZHpyJa8T4i63xqjPYrZ6tKrt55tZJpbXcjSDKuKaf9/polygon/512.png',
3816
+ width: 512,
3817
+ height: 512,
3818
+ format: 'png',
3819
+ },
3820
+ infoURL: 'https://polygon.technology/',
3821
+ name: 'Polygon Amoy Testnet',
3822
+ nativeCurrency: {
3823
+ name: 'MATIC',
3824
+ symbol: 'MATIC',
3825
+ decimals: 18,
3826
+ },
3827
+ networkId: 80002,
3828
+ redFlags: [],
3829
+ rpc: [
3830
+ 'https://rpc-amoy.polygon.technology',
3831
+ ],
3832
+ shortName: 'polygonamoy',
3833
+ slip44: 1,
3834
+ slug: 'polygon-amoy-testnet',
3835
+ testnet: true,
3836
+ title: 'Polygon Amoy Testnet',
3837
+ };
3838
+
3839
+ const chain$5 = {
3840
+ chain: 'Ancient8',
3841
+ chainId: 28122024,
3842
+ explorers: [
3843
+ {
3844
+ name: 'scan-testnet',
3845
+ url: 'https://scanv2-testnet.ancient8.gg',
3846
+ standard: 'EIP3091',
3847
+ },
3848
+ ],
3849
+ faucets: [],
3850
+ icon: {
3851
+ url: 'ipfs://bafkreievnqg3xjokaty4kfbxxbrzm5v5y7exbaaia2txrh4sfgrqsalfym',
3852
+ width: 128,
3853
+ height: 128,
3854
+ format: 'png',
3855
+ },
3856
+ infoURL: 'https://ancient8.gg/',
3857
+ name: 'Ancient8 Testnet',
3858
+ nativeCurrency: {
3859
+ name: 'Ether',
3860
+ symbol: 'ETH',
3861
+ decimals: 18,
3862
+ },
3863
+ networkId: 28122024,
3864
+ rpc: ['https://rpcv2-testnet.ancient8.gg'],
3865
+ shortName: 'a8',
3866
+ slip44: 1,
3867
+ slug: 'ancient8-testnet',
3868
+ testnet: true,
3869
+ };
3870
+
3871
+ const chain$4 = {
3872
+ chain: 'Ancient8',
3873
+ chainId: 888888888,
3874
+ explorers: [
3875
+ {
3876
+ name: 'Ancient8 Explorer',
3877
+ url: 'https://scan.ancient8.gg',
3878
+ standard: 'EIP3091',
3879
+ },
3880
+ ],
3881
+ faucets: [],
3882
+ icon: {
3883
+ url: 'ipfs://bafkreievnqg3xjokaty4kfbxxbrzm5v5y7exbaaia2txrh4sfgrqsalfym',
3884
+ width: 128,
3885
+ height: 128,
3886
+ format: 'png',
3887
+ },
3888
+ infoURL: 'https://ancient8.gg/',
3889
+ name: 'Ancient8',
3890
+ nativeCurrency: {
3891
+ name: 'Ether',
3892
+ symbol: 'ETH',
3893
+ decimals: 18,
3894
+ },
3895
+ networkId: 888888888,
3896
+ rpc: ['https://rpc.ancient8.gg'],
3897
+ shortName: 'ancient8',
3898
+ slug: 'ancient8',
3899
+ testnet: false,
3900
+ };
3901
+
3902
+ const chain$3 = {
3903
+ chain: 'ETH',
3904
+ chainId: 999999999,
3905
+ explorers: [
3906
+ {
3907
+ name: 'Zora Sepolia Testnet Network Explorer',
3908
+ url: 'https://sepolia.explorer.zora.energy',
3909
+ standard: 'EIP3091',
3910
+ },
3911
+ ],
3912
+ faucets: [],
3913
+ icon: {
3914
+ url: 'ipfs://bafkreifvrly5tgd34xqeo67s4etmiu52bkroml7uy7eosizf57htf5nrzq',
3915
+ width: 250,
3916
+ height: 250,
3917
+ format: 'png',
3918
+ },
3919
+ infoURL: 'https://zora.energy',
3920
+ name: 'Zora Sepolia Testnet',
3921
+ nativeCurrency: {
3922
+ name: 'Sepolia Ether',
3923
+ symbol: 'ETH',
3924
+ decimals: 18,
3925
+ },
3926
+ networkId: 999999999,
3927
+ rpc: ['https://sepolia.rpc.zora.energy'],
3928
+ shortName: 'zsep',
3929
+ slip44: 1,
3930
+ slug: 'zora-sepolia-testnet',
3931
+ testnet: true,
3932
+ };
3933
+
3934
+ const chain$2 = {
3935
+ chain: 'ETH',
3936
+ chainId: 7777777,
3937
+ explorers: [
3938
+ {
3939
+ name: 'Zora Network Explorer',
3940
+ url: 'https://explorer.zora.energy',
3941
+ standard: 'EIP3091',
3942
+ },
3943
+ ],
3944
+ faucets: [],
3945
+ features: [],
3946
+ icon: {
3947
+ url: 'ipfs://QmZ6qaRwTPFEZUspwMUjaxC6KhmzcELdRQcQzS3P72Dzts/Vector.svg',
3948
+ width: 512,
3949
+ height: 512,
3950
+ format: 'svg',
3951
+ },
3952
+ infoURL: 'https://zora.energy',
3953
+ name: 'Zora',
3954
+ nativeCurrency: {
3955
+ name: 'Ether',
3956
+ symbol: 'ETH',
3957
+ decimals: 18,
3958
+ },
3959
+ networkId: 7777777,
3960
+ redFlags: [],
3961
+ rpc: ['https://rpc.zora.energy/'],
3962
+ shortName: 'zora',
3963
+ slug: 'zora',
3964
+ testnet: false,
3965
+ };
3966
+
3967
+ const chain$1 = {
3968
+ chain: 'Degen',
3969
+ chainId: 666666666,
3970
+ explorers: [],
3971
+ faucets: [],
3972
+ icon: {
3973
+ url: 'ipfs://Qmb6yAe4wXeBkxjfhxzoUT9TzETcmE7Vne59etm9GJaQf7',
3974
+ width: 789,
3975
+ height: 668,
3976
+ format: 'svg',
3977
+ },
3978
+ infoURL: 'https://degen.tips',
3979
+ name: 'Degen Chain',
3980
+ nativeCurrency: {
3981
+ name: 'DEGEN',
3982
+ symbol: 'DEGEN',
3983
+ decimals: 18,
3984
+ },
3985
+ networkId: 666666666,
3986
+ rpc: ['https://rpc.degen.tips'],
3987
+ shortName: 'degen-chain',
3988
+ slug: 'degen-chain',
3989
+ status: 'incubating',
3990
+ testnet: false,
3991
+ title: 'Degen Chain',
3992
+ };
3993
+
3994
+ const chain = {
3995
+ chain: 'Immutable zkEVM',
3996
+ chainId: 13473,
3997
+ explorers: [
3998
+ {
3999
+ name: 'Immutable Testnet explorer',
4000
+ url: 'https://explorer.testnet.immutable.com',
4001
+ standard: 'EIP3091',
4002
+ icon: {
4003
+ url: 'ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw',
4004
+ width: 1168,
4005
+ height: 1168,
4006
+ format: 'png',
4007
+ },
4008
+ },
4009
+ ],
4010
+ faucets: ['https://docs.immutable.com/docs/zkEVM/guides/faucet'],
4011
+ icon: {
4012
+ url: 'ipfs://QmXFUYFW4e6wifbU9LKVq7owM14bnE6ZbbYq3bn1jBP3Mw',
4013
+ width: 1168,
4014
+ height: 1168,
4015
+ format: 'png',
4016
+ },
4017
+ infoURL: 'https://www.immutable.com',
4018
+ name: 'Immutable zkEVM Testnet',
4019
+ nativeCurrency: {
4020
+ name: 'Test IMX',
4021
+ symbol: 'tIMX',
4022
+ decimals: 18,
4023
+ },
4024
+ networkId: 13473,
4025
+ rpc: [
4026
+ 'https://rpc.testnet.immutable.com',
4027
+ 'https://immutable-zkevm-testnet.drpc.org',
4028
+ 'wss://immutable-zkevm-testnet.drpc.org',
4029
+ ],
4030
+ shortName: 'imx-testnet',
4031
+ slip44: 1,
4032
+ slug: 'immutable-zkevm-testnet',
4033
+ testnet: true,
4034
+ };
4035
+
4036
+ const chainMap = {
4037
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4038
+ 56: chain$m,
4039
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4040
+ 97: chain$l,
4041
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4042
+ 8453: chain$k,
4043
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4044
+ 84532: chain$j,
4045
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4046
+ 4337: chain$i,
4047
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4048
+ 13337: chain$h,
4049
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4050
+ 43113: chain$g,
4051
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4052
+ 43114: chain$f,
4053
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4054
+ 11155111: chain$e,
4055
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4056
+ 59140: chain$d,
4057
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4058
+ 10200: chain$c,
4059
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4060
+ 421614: chain$a,
4061
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4062
+ 42161: chain$9,
4063
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4064
+ 42170: chain$8,
4065
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4066
+ 137: chain$7,
4067
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4068
+ 80002: chain$6,
4069
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4070
+ 28122024: chain$5,
4071
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4072
+ 888888888: chain$4,
4073
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4074
+ 999999999: chain$3,
4075
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4076
+ 7777777: chain$2,
4077
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4078
+ 666666666: chain$1,
4079
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4080
+ 13473: chain,
4081
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4082
+ 13371: chain$b,
4083
+ };
4084
+
4085
+ var BackendTransactionStatus;
4086
+ (function (BackendTransactionStatus) {
4087
+ BackendTransactionStatus["PENDING"] = "PENDING";
4088
+ BackendTransactionStatus["SUBMITTED"] = "SUBMITTED";
4089
+ BackendTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
4090
+ BackendTransactionStatus["REVERTED"] = "REVERTED";
4091
+ BackendTransactionStatus["FAILED"] = "FAILED";
4092
+ BackendTransactionStatus["CANCELLED"] = "CANCELLED";
4093
+ })(BackendTransactionStatus || (BackendTransactionStatus = {}));
4094
+ var ProviderEvent;
4095
+ (function (ProviderEvent) {
4096
+ ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
4097
+ })(ProviderEvent || (ProviderEvent = {}));
4098
+
4099
+ class TypedEventEmitter {
4100
+ emitter = new events.EventEmitter();
4101
+ emit(eventName, ...eventArg) {
4102
+ this.emitter.emit(eventName, ...eventArg);
4103
+ }
4104
+ on(eventName, handler) {
4105
+ this.emitter.on(eventName, handler);
4106
+ }
4107
+ removeListener(eventName, handler) {
4108
+ this.emitter.removeListener(eventName, handler);
4109
+ }
4110
+ }
4111
+
4112
+ /**
4113
+ * ProviderErrors should take priority over RpcErrorCodes
4114
+ * https://eips.ethereum.org/EIPS/eip-1193#provider-errors
4115
+ * https://eips.ethereum.org/EIPS/eip-1474#error-codes
4116
+ */
4117
+ var ProviderErrorCode;
4118
+ (function (ProviderErrorCode) {
4119
+ ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
4120
+ ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
4121
+ ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
4122
+ ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
4123
+ })(ProviderErrorCode || (ProviderErrorCode = {}));
4124
+ var RpcErrorCode;
4125
+ (function (RpcErrorCode) {
4126
+ RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
4127
+ RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
4128
+ RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
4129
+ RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
4130
+ RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
4131
+ RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
4132
+ RpcErrorCode[RpcErrorCode["TRANSACTION_REJECTED"] = -32003] = "TRANSACTION_REJECTED";
4133
+ })(RpcErrorCode || (RpcErrorCode = {}));
4134
+ class JsonRpcError extends Error {
4135
+ message;
4136
+ code;
4137
+ constructor(code, message) {
4138
+ super(message);
4139
+ this.message = message;
4140
+ this.code = code;
4141
+ }
4142
+ }
4143
+
4144
+ const buildOpenfortTransactions = async (transactionRequest, backendApiClients, instanceManager, policyId) => {
4145
+ const interactions = transactionRequest.map((tx) => {
4146
+ if (!tx.to) {
4147
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
4148
+ }
4149
+ return {
4150
+ to: String(tx.to),
4151
+ data: tx.data ? String(tx.data) : undefined,
4152
+ value: tx.value ? String(tx.value) : undefined,
4153
+ };
4154
+ });
4155
+ const accessToken = instanceManager.getAccessToken();
4156
+ const chainId = instanceManager.getChainID();
4157
+ if (!accessToken || !chainId) {
4158
+ throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'No access token found');
4159
+ }
4160
+ const transactionResponse = await backendApiClients.transactionIntentsApi.createTransactionIntent({
4161
+ createTransactionIntentRequest: {
4162
+ policy: policyId,
4163
+ chainId: Number(chainId),
4164
+ interactions,
4165
+ },
4166
+ }, {
4167
+ headers: {
4168
+ authorization: `Bearer ${backendApiClients.config.backend.accessToken}`,
4169
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4170
+ 'x-player-token': accessToken.token,
4171
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4172
+ 'x-auth-provider': accessToken.thirdPartyProvider,
4173
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4174
+ 'x-token-type': accessToken.thirdPartyTokenType,
4175
+ },
4176
+ });
4177
+ return transactionResponse.data;
4178
+ };
4179
+ const sendTransaction = async ({ params, signer, backendClient, instanceManager, policyId, }) => {
4180
+ const openfortTransaction = await buildOpenfortTransactions(params, backendClient, instanceManager, policyId);
4181
+ let response;
4182
+ if (openfortTransaction?.nextAction?.payload?.userOperationHash) {
4183
+ const signature = await signer.sign(openfortTransaction.nextAction.payload.userOperationHash);
4184
+ const openfortSignatureResponse = (await backendClient.transactionIntentsApi.signature({
4185
+ id: openfortTransaction.id,
4186
+ signatureRequest: { signature },
4187
+ })).data.response;
4188
+ if (!openfortSignatureResponse) {
4189
+ throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'Transaction failed to submit');
4190
+ }
4191
+ response = openfortSignatureResponse;
4192
+ }
4193
+ else if (openfortTransaction.response) {
4194
+ response = openfortTransaction.response;
4195
+ }
4196
+ else {
4197
+ throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, 'Transaction failed to submit');
4198
+ }
4199
+ if (response.status === 0 && !response.transactionHash) {
4200
+ throw new JsonRpcError(RpcErrorCode.RPC_SERVER_ERROR, response.error.reason);
4201
+ }
4202
+ return response.transactionHash;
4203
+ };
4204
+
4205
+ const getSignedTypedData = async (typedData, accountType, chainId, signer, evmAddress) => {
4206
+ // Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
4207
+ const types = { ...typedData.types };
4208
+ // @ts-ignore
4209
+ delete types.EIP712Domain;
4210
+ // Hash the EIP712 payload and generate the complete payload
4211
+ let typedDataHash = hash._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
4212
+ if (accountType === AccountType.UPGRADEABLE_V5) {
4213
+ const updatedDomain = {
4214
+ name: 'Openfort',
4215
+ version: '0.5',
4216
+ chainId: Number(chainId),
4217
+ verifyingContract: evmAddress,
4218
+ };
4219
+ const updatedTypes = {
4220
+ // eslint-disable-next-line @typescript-eslint/naming-convention
4221
+ OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
4222
+ };
4223
+ const updatedMessage = {
4224
+ hashedMessage: typedDataHash,
4225
+ };
4226
+ typedDataHash = hash._TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
4227
+ // primaryType: "OpenfortMessage"
4228
+ }
4229
+ const ethsigNoType = await signer.sign(typedDataHash, false, false);
4230
+ return ethsigNoType;
4231
+ };
4232
+
4233
+ const REQUIRED_TYPED_DATA_PROPERTIES = ['types', 'domain', 'primaryType', 'message'];
4234
+ const isValidTypedDataPayload = (typedData) => (REQUIRED_TYPED_DATA_PROPERTIES.every((key) => key in typedData));
4235
+ const transformTypedData = (typedData, chainId) => {
4236
+ let transformedTypedData;
4237
+ if (typeof typedData === 'string') {
4238
+ try {
4239
+ transformedTypedData = JSON.parse(typedData);
4240
+ }
4241
+ catch (err) {
4242
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Failed to parse typed data JSON: ${err}`);
4243
+ }
4244
+ }
4245
+ else if (typeof typedData === 'object') {
4246
+ transformedTypedData = typedData;
4247
+ }
4248
+ else {
4249
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Invalid typed data argument: ${typedData}`);
4250
+ }
4251
+ if (!isValidTypedDataPayload(transformedTypedData)) {
4252
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Invalid typed data argument. The following properties are required:
4253
+ ${REQUIRED_TYPED_DATA_PROPERTIES.join(', ')}`);
4254
+ }
4255
+ const providedChainId = transformedTypedData.domain?.chainId;
4256
+ if (providedChainId) {
4257
+ // domain.chainId (if defined) can be a number, string, or hex value, but the backend & guardian only accept a number.
4258
+ if (typeof providedChainId === 'string') {
4259
+ if (providedChainId.startsWith('0x')) {
4260
+ transformedTypedData.domain.chainId = parseInt(providedChainId, 16);
4261
+ }
4262
+ else {
4263
+ transformedTypedData.domain.chainId = parseInt(providedChainId, 10);
4264
+ }
4265
+ }
4266
+ if (transformedTypedData.domain.chainId !== chainId) {
4267
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `Invalid chainId, expected ${chainId}`);
4268
+ }
4269
+ }
4270
+ return transformedTypedData;
4271
+ };
4272
+ const signTypedDataV4 = async ({ params, method, signer, accountType, rpcProvider, }) => {
4273
+ const fromAddress = params[0];
4274
+ const typedDataParam = params[1];
4275
+ if (!fromAddress || !typedDataParam) {
4276
+ throw new JsonRpcError(RpcErrorCode.INVALID_PARAMS, `${method} requires an address and a typed data JSON`);
4277
+ }
4278
+ const { chainId } = await rpcProvider.detectNetwork();
4279
+ const typedData = transformTypedData(typedDataParam, chainId);
4280
+ const signature = await getSignedTypedData(typedData, accountType, chainId, signer, fromAddress);
4281
+ return signature;
4282
+ };
4283
+
4284
+ class EvmProvider {
4285
+ #signer;
4286
+ #policyId;
4287
+ #eventEmitter;
4288
+ #rpcProvider; // Used for read
4289
+ #instanceManager;
4290
+ #backendApiClients;
4291
+ #address;
4292
+ isOpenfort = true;
4293
+ constructor({ signer, address, backendApiClients, instanceManager, openfortEventEmitter, policyId, }) {
4294
+ this.#signer = signer;
4295
+ this.#policyId = policyId;
4296
+ this.#address = address;
4297
+ this.#instanceManager = instanceManager;
4298
+ this.#backendApiClients = backendApiClients;
4299
+ const chainId = Number(this.#instanceManager.getChainID());
4300
+ this.#rpcProvider = new providers.StaticJsonRpcProvider(chainMap[chainId].rpc[0]);
4301
+ this.#backendApiClients = backendApiClients;
4302
+ this.#eventEmitter = new TypedEventEmitter();
4303
+ openfortEventEmitter.on(OpenfortEvents.LOGGED_OUT, this.#handleLogout);
4304
+ }
4305
+ #handleLogout = () => {
4306
+ const shouldEmitAccountsChanged = !!this.#address;
4307
+ this.#address = undefined;
4308
+ this.#signer.logout();
4309
+ if (shouldEmitAccountsChanged) {
4310
+ this.#eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, []);
4311
+ }
4312
+ };
4313
+ async #performRequest(request) {
4314
+ switch (request.method) {
4315
+ case 'eth_requestAccounts': {
4316
+ if (this.#address) {
4317
+ return [this.#address];
4318
+ }
4319
+ const user = await this.#signer.ensureEmbeddedAccount();
4320
+ this.#address = user.address;
4321
+ this.#eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [this.#address]);
4322
+ return [this.#address];
4323
+ }
4324
+ case 'eth_sendTransaction': {
4325
+ if (!this.#address) {
4326
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorized - call eth_requestAccounts first');
4327
+ }
4328
+ return await sendTransaction({
4329
+ params: request.params || [],
4330
+ signer: this.#signer,
4331
+ backendClient: this.#backendApiClients,
4332
+ instanceManager: this.#instanceManager,
4333
+ policyId: this.#policyId,
4334
+ });
4335
+ }
4336
+ case 'eth_accounts': {
4337
+ return this.#address ? [this.#address] : [];
4338
+ }
4339
+ case 'eth_signTypedData':
4340
+ case 'eth_signTypedData_v4': {
4341
+ if (!this.#address) {
4342
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorized - call eth_requestAccounts first');
4343
+ }
4344
+ const accountType = this.#instanceManager.getAccountType();
4345
+ if (!accountType) {
4346
+ throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorized - call eth_requestAccounts first');
4347
+ }
4348
+ return await signTypedDataV4({
4349
+ method: request.method,
4350
+ params: request.params || [],
4351
+ signer: this.#signer,
4352
+ accountType,
4353
+ rpcProvider: this.#rpcProvider,
4354
+ });
4355
+ }
4356
+ case 'eth_chainId': {
4357
+ // Call detect network to fetch the chainId so to take advantage of
4358
+ // the caching layer provided by StaticJsonRpcProvider.
4359
+ // In case Openfort is changed from StaticJsonRpcProvider to a
4360
+ // JsonRpcProvider, this function will still work as expected given
4361
+ // that detectNetwork call _uncachedDetectNetwork which will force
4362
+ // the provider to re-fetch the chainId from remote.
4363
+ const { chainId } = await this.#rpcProvider.detectNetwork();
4364
+ return bytes.hexlify(chainId);
4365
+ }
4366
+ // Pass through methods
4367
+ case 'eth_gasPrice':
4368
+ case 'eth_getBalance':
4369
+ case 'eth_getCode':
4370
+ case 'eth_getStorageAt':
4371
+ case 'eth_estimateGas':
4372
+ case 'eth_call':
4373
+ case 'eth_blockNumber':
4374
+ case 'eth_getBlockByHash':
4375
+ case 'eth_getBlockByNumber':
4376
+ case 'eth_getTransactionByHash':
4377
+ case 'eth_getTransactionReceipt':
4378
+ case 'eth_getTransactionCount': {
4379
+ return this.#rpcProvider.send(request.method, request.params || []);
4380
+ }
4381
+ default: {
4382
+ throw new JsonRpcError(ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
4383
+ }
4384
+ }
4385
+ }
4386
+ async #performJsonRpcRequest(request) {
4387
+ const { id, jsonrpc } = request;
4388
+ try {
4389
+ const result = await this.#performRequest(request);
4390
+ return {
4391
+ id,
4392
+ jsonrpc,
4393
+ result,
4394
+ };
4395
+ }
4396
+ catch (error) {
4397
+ let jsonRpcError;
4398
+ if (error instanceof JsonRpcError) {
4399
+ jsonRpcError = error;
4400
+ }
4401
+ else if (error instanceof Error) {
4402
+ jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
4403
+ }
4404
+ else {
4405
+ jsonRpcError = new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
4406
+ }
4407
+ return {
4408
+ id,
4409
+ jsonrpc,
4410
+ error: jsonRpcError,
4411
+ };
4412
+ }
4413
+ }
4414
+ async request(request) {
4415
+ try {
4416
+ return this.#performRequest(request);
4417
+ }
4418
+ catch (error) {
4419
+ if (error instanceof JsonRpcError) {
4420
+ throw error;
4421
+ }
4422
+ if (error instanceof Error) {
4423
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, error.message);
4424
+ }
4425
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Internal error');
4426
+ }
4427
+ }
4428
+ sendAsync(request, callback) {
4429
+ if (!callback) {
4430
+ throw new Error('No callback provided');
4431
+ }
4432
+ if (Array.isArray(request)) {
4433
+ Promise.all(request.map(this.#performJsonRpcRequest)).then((result) => {
4434
+ callback(null, result);
4435
+ }).catch((error) => {
4436
+ callback(error, []);
4437
+ });
4438
+ }
4439
+ else {
4440
+ this.#performJsonRpcRequest(request).then((result) => {
4441
+ callback(null, result);
4442
+ }).catch((error) => {
4443
+ callback(error, null);
4444
+ });
4445
+ }
4446
+ }
4447
+ async send(request, callbackOrParams, callback) {
4448
+ // Web3 >= 1.0.0-beta.38 calls `send` with method and parameters.
4449
+ if (typeof request === 'string') {
4450
+ if (typeof callbackOrParams === 'function') {
4451
+ return this.sendAsync({
4452
+ method: request,
4453
+ params: [],
4454
+ }, callbackOrParams);
4455
+ }
4456
+ if (callback) {
4457
+ return this.sendAsync({
4458
+ method: request,
4459
+ params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
4460
+ }, callback);
4461
+ }
4462
+ return this.request({
4463
+ method: request,
4464
+ params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
4465
+ });
4466
+ }
4467
+ // Web3 <= 1.0.0-beta.37 uses `send` with a callback for async queries.
4468
+ if (typeof callbackOrParams === 'function') {
4469
+ return this.sendAsync(request, callbackOrParams);
4470
+ }
4471
+ if (!Array.isArray(request) && typeof request === 'object') {
4472
+ return this.#performJsonRpcRequest(request);
4473
+ }
4474
+ throw new JsonRpcError(RpcErrorCode.INVALID_REQUEST, 'Invalid request');
4475
+ }
4476
+ on(event, listener) {
4477
+ this.#eventEmitter.on(event, listener);
4478
+ }
4479
+ removeListener(event, listener) {
4480
+ this.#eventEmitter.removeListener(event, listener);
4481
+ }
4482
+ }
4483
+
4484
+ const openfortProviderInfo = {
4485
+ // eslint-disable-next-line max-len
4486
+ icon: 'data:image/svg+xml,<svg aria-hidden="true" viewBox="597.32 331.34 171.36 105.32" ><g><rect x="673.9" y="404.26" width="18.2" height="32.4" /><polygon points="768.68,331.36 768.68,331.36 768.68,331.34 610.78,331.34 610.78,331.36 597.32,331.36 597.32,436.64 615.52,436.64 615.52,349.54 750.48,349.54 750.48,436.64 768.68,436.64 " /><polygon points="732.16,367.79 633.83,367.79 633.83,370.19 633.79,370.19 633.79,436.64 651.99,436.64 651.99,385.99 713.9,385.99 713.9,436.64 732.09,436.64 732.09,385.99 732.16,385.99 " /></g></svg>',
4487
+ name: 'Ecosystem ID',
4488
+ rdns: 'com.ecosystem.id',
4489
+ uuid: uuid.v4(),
4490
+ };
4491
+ function announceProvider(detail) {
4492
+ if (typeof window === 'undefined')
4493
+ return;
4494
+ const event = new CustomEvent('eip6963:announceProvider', { detail: Object.freeze(detail) });
4495
+ window.dispatchEvent(event);
4496
+ const handler = () => window.dispatchEvent(event);
4497
+ window.addEventListener('eip6963:requestProvider', handler);
4498
+ }
4499
+
3052
4500
  var SignerType;
3053
4501
  (function (SignerType) {
3054
4502
  SignerType["EMBEDDED"] = "embedded";
@@ -3254,7 +4702,7 @@ class AuthManager {
3254
4702
  headers: {
3255
4703
  authorization: `Bearer ${this.config.baseConfiguration.publishableKey}`,
3256
4704
  // eslint-disable-next-line @typescript-eslint/naming-convention
3257
- 'player-token': accessToken,
4705
+ 'x-player-token': accessToken,
3258
4706
  },
3259
4707
  });
3260
4708
  }
@@ -4073,6 +5521,13 @@ class NotLoggedIn extends Error {
4073
5521
  Object.setPrototypeOf(this, NotLoggedIn.prototype);
4074
5522
  }
4075
5523
  }
5524
+ class EmbeddedNotConfigured extends Error {
5525
+ constructor(message) {
5526
+ super(message);
5527
+ this.name = 'EmbeddedNotConfigured';
5528
+ Object.setPrototypeOf(this, EmbeddedNotConfigured.prototype);
5529
+ }
5530
+ }
4076
5531
  class NoSignerConfigured extends Error {
4077
5532
  constructor(message) {
4078
5533
  super(message);
@@ -4094,11 +5549,13 @@ class Openfort {
4094
5549
  instanceManager;
4095
5550
  backendApiClients;
4096
5551
  iframeManager;
5552
+ openfortEventEmitter;
4097
5553
  constructor(sdkConfiguration) {
4098
5554
  this.config = new SDKConfiguration(sdkConfiguration);
4099
5555
  this.backendApiClients = new BackendApiClients(this.config.openfortAPIConfig);
4100
5556
  this.authManager = new AuthManager(this.config, this.backendApiClients);
4101
5557
  this.instanceManager = new InstanceManager(new SessionStorage(), new LocalStorage(), new LocalStorage(), this.authManager);
5558
+ this.openfortEventEmitter = new TypedEventEmitter();
4102
5559
  this.iframeManager = new IframeManager(this.config);
4103
5560
  }
4104
5561
  async logout() {
@@ -4130,6 +5587,29 @@ class Openfort {
4130
5587
  this.instanceManager.removeJWK();
4131
5588
  }
4132
5589
  }
5590
+ getEthereumProvider(options = {
5591
+ announceProvider: true,
5592
+ }) {
5593
+ if (!(this.signer instanceof EmbeddedSigner)) {
5594
+ throw new EmbeddedNotConfigured('Embedded signer must be configured to get Ethereum provider');
5595
+ }
5596
+ const address = this.instanceManager.getAccountAddress();
5597
+ const provider = new EvmProvider({
5598
+ openfortEventEmitter: this.openfortEventEmitter,
5599
+ signer: this.signer,
5600
+ address: address,
5601
+ instanceManager: this.instanceManager,
5602
+ backendApiClients: this.backendApiClients,
5603
+ policyId: options.policy,
5604
+ });
5605
+ if (options?.announceProvider) {
5606
+ announceProvider({
5607
+ info: openfortProviderInfo,
5608
+ provider,
5609
+ });
5610
+ }
5611
+ return provider;
5612
+ }
4133
5613
  async flushSigner() {
4134
5614
  if (this.signer) {
4135
5615
  await this.signer.logout();