@imtbl/sdk 0.28.10 → 0.29.0-alpha.1
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/README.md +147 -0
- package/dist/blockchain_data.d.ts +14 -5
- package/dist/blockchain_data.js +4 -4
- package/dist/browser/checkout/sdk.js +35 -0
- package/dist/browser/checkout/widgets.js +890 -0
- package/dist/checkout_sdk.d.ts +1308 -371
- package/dist/checkout_sdk.js +2896 -2421
- package/dist/config.d.ts +18 -6
- package/dist/config.js +21 -20
- package/dist/immutablex_client.d.ts +14 -5
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3098 -3010
- package/dist/index.d.ts +1563 -15565
- package/dist/index.js +3101 -3012
- package/dist/orderbook.d.ts +14 -5
- package/dist/passport.d.ts +14 -5
- package/dist/passport.js +146 -98
- package/dist/provider.d.ts +14 -5
- package/package.json +17 -6
- package/dist/browser/checkout.js +0 -2
- package/dist/checkout_widgets.d.ts +0 -25605
- package/dist/checkout_widgets.js +0 -450
package/README.md
CHANGED
|
@@ -27,3 +27,150 @@ npm install @imtbl/sdk
|
|
|
27
27
|
# or
|
|
28
28
|
yarn add @imtbl/sdk
|
|
29
29
|
```
|
|
30
|
+
|
|
31
|
+
## Changelog
|
|
32
|
+
|
|
33
|
+
### [0.29.0] - 13-11-2023
|
|
34
|
+
|
|
35
|
+
#### Changed (breaking)
|
|
36
|
+
|
|
37
|
+
##### The `connectImx` method no longer registers users on Immutable X
|
|
38
|
+
|
|
39
|
+
This method was previously responsible for automatically [registering a user](https://docs.immutable.com/docs/x/how-to-register-users/)
|
|
40
|
+
the first time they connect to Immutable X.
|
|
41
|
+
|
|
42
|
+
###### Before
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const passport = new Passport(...);
|
|
46
|
+
const provider = await passport.connectImx();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
###### After
|
|
50
|
+
|
|
51
|
+
Passport now allows you to manage the registration process yourself through the `isRegisteredOffchain` and
|
|
52
|
+
`registerOffchain` functions.
|
|
53
|
+
|
|
54
|
+
This gives you the advantage of potentially displaying a custom UI informing the user that they’re being registered,
|
|
55
|
+
as opposed to the previous experience where the user was waiting until the `connectImx` step completed all the steps.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const passport = new Passport(...);
|
|
59
|
+
const provider = await passport.connectImx();
|
|
60
|
+
|
|
61
|
+
if (!await provider.isRegisteredOffchain()) {
|
|
62
|
+
// Potentially inform the user the user that are about to be
|
|
63
|
+
// registered on Immutable X
|
|
64
|
+
await provider.registerOffchain();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The user's wallet is registered, they are now ready to use Immutable X
|
|
68
|
+
const response = await provider.transfer(...);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
##### Passport is now a client-side only module
|
|
72
|
+
|
|
73
|
+
This change is only relevant if you are using server-side rendering (SSR).
|
|
74
|
+
|
|
75
|
+
Passport has a dependency on browser-specific primitives, such as the `window` object, and therefore is intended to be
|
|
76
|
+
used in a client-side environment only.
|
|
77
|
+
|
|
78
|
+
Depending on your framework, you may need to update how you were instantiating the Passport instance to ensure
|
|
79
|
+
this happens on the client.
|
|
80
|
+
|
|
81
|
+
### [0.28.2] - 30-10-2023
|
|
82
|
+
|
|
83
|
+
#### Added
|
|
84
|
+
|
|
85
|
+
We have added a new `login` method that allows you to authenticate users without necessarily instantiating their wallets.
|
|
86
|
+
|
|
87
|
+
##### Before
|
|
88
|
+
|
|
89
|
+
Previously, you had to authenticate users as follows:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const passport = new Passport(...);
|
|
93
|
+
const provider = await passport.connectImx();
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The `connectImx` function performed the following tasks under the hood:
|
|
97
|
+
|
|
98
|
+
- Completed the OIDC authentication flow to log the user in
|
|
99
|
+
- Instantiated their wallet based on their identity
|
|
100
|
+
- Registered the user on the Immutable X ecosystem
|
|
101
|
+
|
|
102
|
+
Although this simple API was simple and convenient, we have decided to decouple it into explicit methods based on customer feedback to provide you with more flexibility.
|
|
103
|
+
|
|
104
|
+
##### After
|
|
105
|
+
|
|
106
|
+
From now on, you can authenticate users as follows:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const passport = new Passport(...);
|
|
110
|
+
const user = await passport.login();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The login method only authenticates the user. This allows you to separate the authentication process from wallet
|
|
114
|
+
instantiation and the registration step, giving you greater control and flexibility in managing user
|
|
115
|
+
authentication within your application.
|
|
116
|
+
|
|
117
|
+
This is especially useful if your application only uses Passport for authentication and does not leverage
|
|
118
|
+
the wallet component.
|
|
119
|
+
|
|
120
|
+
However, if you want to instantiate the wallet, you can do so as follows:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const passport = new Passport(...);
|
|
124
|
+
const user = await passport.login(); // Optional
|
|
125
|
+
|
|
126
|
+
const provider = await passport.connectImx();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Depending on your application, you may decide to only log in the user when they click on “Sign in with Passport”
|
|
130
|
+
using `login`, and instantiate the wallet using `connectImx` in the background, ensuring a seamless
|
|
131
|
+
and user-friendly experience.
|
|
132
|
+
|
|
133
|
+
Note that the `connectImx` method will attempt to log the user in automatically if you haven’t explicitly called login
|
|
134
|
+
before connecting to Immutable X.
|
|
135
|
+
|
|
136
|
+
The following code will have the same outcome as the snippet above, but it's important to note that the `Promise`
|
|
137
|
+
returned by `connectImx` will not resolve until the user has successfully logged in and their wallet has been
|
|
138
|
+
instantiated, potentially leading to a less streamlined user experience.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const passport = new Passport(...);
|
|
142
|
+
const provider = await passport.connectImx();
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Find more information about authenticating users in the [Passport Login documentation](https://docs.immutable.com/docs/x/passport/identity/login#1-trigger-the-login-process).
|
|
146
|
+
|
|
147
|
+
#### Deprecated
|
|
148
|
+
|
|
149
|
+
Following the introduction of the `login` method, we have deprecated the `connectImxSilent` method.
|
|
150
|
+
|
|
151
|
+
This method was previously used for [rehydrating the session of previously authenticated users](https://docs.immutable.com/docs/x/passport/identity/login/#3-maintaining-the-login-status)
|
|
152
|
+
on page reloads.
|
|
153
|
+
|
|
154
|
+
##### Before
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
// On page load, attempt to re-authenticate the user without propting them to
|
|
158
|
+
// sign in based on their cached session and initialise the wallet.
|
|
159
|
+
const provider = await passport.connectImxSilent();
|
|
160
|
+
|
|
161
|
+
if (!provider) {
|
|
162
|
+
// The user session couldn't be recovered. The user will have to explicitly
|
|
163
|
+
// sign in again by clicking a button that trigger passport.connectImx()
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
##### After
|
|
168
|
+
```ts
|
|
169
|
+
// On page load, attempt to re-authenticate the user without propting them to
|
|
170
|
+
// sign in based on their cached session.
|
|
171
|
+
const user = await passport.login({ useCachedSession: true });
|
|
172
|
+
if (user) {
|
|
173
|
+
// The user session is still valid, we can now initialise the wallet
|
|
174
|
+
const provider = await passport.connectImx();
|
|
175
|
+
}
|
|
176
|
+
```
|
|
@@ -3689,16 +3689,25 @@ declare class ImmutableConfiguration {
|
|
|
3689
3689
|
readonly environment: Environment;
|
|
3690
3690
|
readonly rateLimitingKey?: string;
|
|
3691
3691
|
readonly apiKey?: string;
|
|
3692
|
-
readonly
|
|
3692
|
+
readonly publishableKey?: string;
|
|
3693
3693
|
constructor(options: {
|
|
3694
3694
|
environment: Environment;
|
|
3695
|
-
rateLimitingKey?: string;
|
|
3696
|
-
apiKey?: string;
|
|
3697
|
-
clientAppId?: string;
|
|
3698
3695
|
});
|
|
3699
3696
|
}
|
|
3697
|
+
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
3698
|
+
apiKey: 'required';
|
|
3699
|
+
} ? Required<{
|
|
3700
|
+
apiKey: string;
|
|
3701
|
+
}> : {}) & (T extends {
|
|
3702
|
+
publishableKey: 'required';
|
|
3703
|
+
} ? Required<{
|
|
3704
|
+
publishableKey: string;
|
|
3705
|
+
}> : {});
|
|
3706
|
+
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
3707
|
+
apiKey: 'omit';
|
|
3708
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
3700
3709
|
interface ModuleConfiguration<T> {
|
|
3701
|
-
baseConfig:
|
|
3710
|
+
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
3702
3711
|
overrides?: T;
|
|
3703
3712
|
}
|
|
3704
3713
|
|
package/dist/blockchain_data.js
CHANGED
|
@@ -666,7 +666,7 @@ const CollectionsApiAxiosParamCreator = function (configuration) {
|
|
|
666
666
|
const localVarHeaderParameter = {};
|
|
667
667
|
const localVarQueryParameter = {};
|
|
668
668
|
// authentication ImmutableApiKey required
|
|
669
|
-
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-
|
|
669
|
+
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
|
|
670
670
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
671
671
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
672
672
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -976,7 +976,7 @@ const MetadataApiAxiosParamCreator = function (configuration) {
|
|
|
976
976
|
const localVarHeaderParameter = {};
|
|
977
977
|
const localVarQueryParameter = {};
|
|
978
978
|
// authentication ImmutableApiKey required
|
|
979
|
-
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-
|
|
979
|
+
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
|
|
980
980
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
981
981
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
982
982
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -1016,7 +1016,7 @@ const MetadataApiAxiosParamCreator = function (configuration) {
|
|
|
1016
1016
|
const localVarHeaderParameter = {};
|
|
1017
1017
|
const localVarQueryParameter = {};
|
|
1018
1018
|
// authentication ImmutableApiKey required
|
|
1019
|
-
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-
|
|
1019
|
+
await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
|
|
1020
1020
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
1021
1021
|
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
1022
1022
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -3479,7 +3479,7 @@ class APIError extends Error {
|
|
|
3479
3479
|
|
|
3480
3480
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3481
3481
|
const defaultHeaders = {
|
|
3482
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
3482
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.29.0-alpha.1',
|
|
3483
3483
|
};
|
|
3484
3484
|
/**
|
|
3485
3485
|
* createAPIConfiguration to create a custom Configuration
|