@openfort/openfort-js 0.7.1 → 0.7.3

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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { SessionKey, AuthResponse, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse, TokenType as TokenType$1, SIWEInitResponse, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1, AuthPlayerResponse as AuthPlayerResponse$1, TransactionIntentResponse as TransactionIntentResponse$1, SessionResponse as SessionResponse$1, EmbeddedState as EmbeddedState$1 } from 'types';
2
- import { SDKConfiguration } from 'config';
1
+ import { SessionKey, AuthResponse, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse, TokenType as TokenType$1, SIWEInitResponse, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1, AuthPlayerResponse as AuthPlayerResponse$1, TransactionIntentResponse as TransactionIntentResponse$1, SessionResponse as SessionResponse$1, EmbeddedState as EmbeddedState$1, SDKOverrides as SDKOverrides$1 } from 'types';
2
+ import { SDKConfiguration as SDKConfiguration$1 } from 'config';
3
+ import { Provider as Provider$1 } from 'evm/types';
3
4
 
4
5
  declare type Bytes = ArrayLike<number>;
5
6
  declare type BytesLike = Bytes | string;
@@ -73,15 +74,22 @@ declare class Openfort {
73
74
  private readonly instanceManager;
74
75
  private readonly backendApiClients;
75
76
  private readonly iframeManager;
76
- constructor(sdkConfiguration: SDKConfiguration);
77
+ private readonly openfortEventEmitter;
78
+ constructor(sdkConfiguration: SDKConfiguration$1);
77
79
  logout(): Promise<void>;
80
+ getEthereumProvider(options?: {
81
+ announceProvider: boolean;
82
+ policy?: string;
83
+ }): Provider$1;
78
84
  private flushSigner;
79
85
  configureSessionKey(): SessionKey;
80
86
  configureEmbeddedSigner(chainId?: number, shieldAuthentication?: ShieldAuthentication, recoveryPassword?: string): Promise<void>;
81
87
  private newEmbeddedSigner;
82
88
  loginWithEmailPassword(email: string, password: string): Promise<AuthResponse>;
83
89
  signUpWithEmailPassword(email: string, password: string, name?: string): Promise<AuthResponse>;
84
- initOAuth(provider: OAuthProvider$1, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
90
+ initOAuth(provider: OAuthProvider$1, usePooling?: boolean, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
91
+ initLinkOAuth(provider: OAuthProvider$1, playerToken: string, usePooling?: boolean, options?: InitializeOAuthOptions$1): Promise<InitAuthResponse>;
92
+ poolOAuth(key: string): Promise<AuthResponse>;
85
93
  authenticateWithOAuth(provider: OAuthProvider$1, token: string, tokenType: TokenType$1): Promise<AuthResponse>;
86
94
  initSIWE(address: string): Promise<SIWEInitResponse>;
87
95
  authenticateWithThirdPartyProvider(provider: ThirdPartyOAuthProvider$1, token: string, tokenType: TokenType$1): Promise<AuthPlayerResponse$1>;
@@ -152,25 +160,27 @@ declare enum ThirdPartyOAuthProvider {
152
160
  CUSTOM = "custom",
153
161
  OIDC = "oidc"
154
162
  }
163
+ declare enum BasicAuthProvider {
164
+ EMAIL = "email",
165
+ WALLET = "wallet"
166
+ }
155
167
  declare const AUTH_PROVIDER: {
156
- email: 'email';
157
- accelbyte: 'accelbyte';
158
- firebase: 'firebase';
159
- google: 'google';
160
- lootlocker: 'lootlocker';
161
- playfab: 'playfab';
162
- wallet: 'wallet';
168
+ readonly email: "email";
169
+ readonly wallet: "wallet";
170
+ readonly google: "google";
171
+ readonly twitter: "twitter";
172
+ readonly accelbyte: "accelbyte";
173
+ readonly firebase: "firebase";
174
+ readonly lootlocker: "lootlocker";
175
+ readonly playfab: "playfab";
176
+ readonly supabase: "supabase";
177
+ readonly custom: "custom";
178
+ readonly oidc: "oidc";
163
179
  };
164
180
  type AuthProvider = typeof AUTH_PROVIDER[keyof typeof AUTH_PROVIDER];
165
181
  declare enum OAuthProvider {
166
- ACCELBYTE = "accelbyte",
167
- FIREBASE = "firebase",
168
182
  GOOGLE = "google",
169
- LOOTLOCKER = "lootlocker",
170
- PLAYFAB = "playfab",
171
- CUSTOM = "custom",
172
- OIDC = "oidc",
173
- SUPABASE = "supabase"
183
+ TWITTER = "twitter"
174
184
  }
175
185
  interface NextActionPayload {
176
186
  'userOp'?: any;
@@ -358,6 +368,150 @@ interface AuthPlayerResponse {
358
368
  'linkedAccounts': Array<LinkedAccountResponse>;
359
369
  }
360
370
 
371
+ /**
372
+ * ProviderErrors should take priority over RpcErrorCodes
373
+ * https://eips.ethereum.org/EIPS/eip-1193#provider-errors
374
+ * https://eips.ethereum.org/EIPS/eip-1474#error-codes
375
+ */
376
+ declare enum ProviderErrorCode {
377
+ USER_REJECTED_REQUEST = 4001,
378
+ UNAUTHORIZED = 4100,
379
+ UNSUPPORTED_METHOD = 4200,
380
+ DISCONNECTED = 4900
381
+ }
382
+ declare enum RpcErrorCode {
383
+ RPC_SERVER_ERROR = -32000,
384
+ INVALID_REQUEST = -32600,
385
+ METHOD_NOT_FOUND = -32601,
386
+ INVALID_PARAMS = -32602,
387
+ INTERNAL_ERROR = -32603,
388
+ PARSE_ERROR = -32700,
389
+ TRANSACTION_REJECTED = -32003
390
+ }
391
+ declare class JsonRpcError extends Error {
392
+ readonly message: string;
393
+ readonly code: ProviderErrorCode | RpcErrorCode;
394
+ constructor(code: ProviderErrorCode | RpcErrorCode, message: string);
395
+ }
396
+
397
+ interface RequestArguments {
398
+ method: string;
399
+ params?: Array<any>;
400
+ }
401
+ type JsonRpcRequestPayload = RequestArguments & {
402
+ jsonrpc?: string;
403
+ id?: string | number;
404
+ };
405
+ interface JsonRpcRequestCallback {
406
+ (err: JsonRpcError | null, result?: JsonRpcResponsePayload | (JsonRpcResponsePayload | null)[] | null): void;
407
+ }
408
+ interface JsonRpcResponsePayload {
409
+ result?: Array<any> | null;
410
+ error?: JsonRpcError | null;
411
+ jsonrpc?: string;
412
+ id?: string | number;
413
+ }
414
+ type Provider = {
415
+ request: (request: RequestArguments) => Promise<any>;
416
+ sendAsync: (request: JsonRpcRequestPayload | JsonRpcRequestPayload[], callback: JsonRpcRequestCallback) => void;
417
+ send: (request: string | JsonRpcRequestPayload | JsonRpcRequestPayload[], callbackOrParams?: JsonRpcRequestCallback | Array<any>, callback?: JsonRpcRequestCallback) => void;
418
+ on: (event: string, listener: (...args: any[]) => void) => void;
419
+ removeListener: (event: string, listener: (...args: any[]) => void) => void;
420
+ isOpenfort: boolean;
421
+ };
422
+
423
+ /**
424
+ * Openfort API
425
+ * Complete Openfort API references and guides can be found at: https://openfort.xyz/docs
426
+ *
427
+ * The version of the OpenAPI document: 1.0.0
428
+ * Contact: founders@openfort.xyz
429
+ *
430
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
431
+ * https://openapi-generator.tech
432
+ * Do not edit the class manually.
433
+ */
434
+ interface ConfigurationParameters {
435
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
436
+ username?: string;
437
+ password?: string;
438
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
439
+ basePath?: string;
440
+ baseOptions?: any;
441
+ formDataCtor?: new () => any;
442
+ }
443
+ declare class Configuration {
444
+ /**
445
+ * parameter for apiKey security
446
+ * @param name security name
447
+ * @memberof Configuration
448
+ */
449
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
450
+ /**
451
+ * parameter for basic security
452
+ *
453
+ * @type {string}
454
+ * @memberof Configuration
455
+ */
456
+ username?: string;
457
+ /**
458
+ * parameter for basic security
459
+ *
460
+ * @type {string}
461
+ * @memberof Configuration
462
+ */
463
+ password?: string;
464
+ /**
465
+ * parameter for oauth2 security
466
+ * @param name security name
467
+ * @param scopes oauth2 scope
468
+ * @memberof Configuration
469
+ */
470
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
471
+ /**
472
+ * override base path
473
+ *
474
+ * @type {string}
475
+ * @memberof Configuration
476
+ */
477
+ basePath?: string;
478
+ /**
479
+ * base options for axios calls
480
+ *
481
+ * @type {any}
482
+ * @memberof Configuration
483
+ */
484
+ baseOptions?: any;
485
+ /**
486
+ * The FormData constructor that will be used to create multipart form data
487
+ * requests. You can inject this here so that execution environments that
488
+ * do not support the FormData class can still run the generated client.
489
+ *
490
+ * @type {new () => FormData}
491
+ */
492
+ formDataCtor?: new () => any;
493
+ constructor(param?: ConfigurationParameters);
494
+ /**
495
+ * Check if the given MIME is a JSON MIME.
496
+ * JSON MIME examples:
497
+ * application/json
498
+ * application/json; charset=UTF8
499
+ * APPLICATION/JSON
500
+ * application/vnd.company+json
501
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
502
+ * @return True if the given MIME is JSON, false otherwise.
503
+ */
504
+ isJsonMime(mime: string): boolean;
505
+ }
506
+
507
+ /**
508
+ * Configuration for generated clients
509
+ */
510
+ type BackendAPIConfiguration = Configuration;
511
+ type OpenfortAPIConfiguration = {
512
+ backend: BackendAPIConfiguration;
513
+ };
514
+
361
515
  declare class OpenfortConfiguration {
362
516
  readonly publishableKey: string;
363
517
  constructor(options: {
@@ -374,5 +528,18 @@ declare class ShieldConfiguration {
374
528
  shieldDebug?: boolean;
375
529
  });
376
530
  }
531
+ declare class SDKConfiguration {
532
+ readonly baseConfiguration: OpenfortConfiguration;
533
+ readonly shieldConfiguration?: ShieldConfiguration;
534
+ readonly shieldUrl: string;
535
+ readonly iframeUrl: string;
536
+ readonly backendUrl: string;
537
+ readonly openfortAPIConfig: OpenfortAPIConfiguration;
538
+ constructor({ baseConfiguration, shieldConfiguration, overrides, }: {
539
+ baseConfiguration: OpenfortConfiguration;
540
+ shieldConfiguration?: ShieldConfiguration;
541
+ overrides?: SDKOverrides$1;
542
+ });
543
+ }
377
544
 
378
- export { AuthPlayerResponse, AuthType, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };
545
+ export { AuthPlayerResponse, AuthType, BasicAuthProvider, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, Provider, SDKConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };