@scayle/storefront-core 8.3.2 → 8.4.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/CHANGELOG.md +6 -0
- package/dist/api/customer.cjs +16 -10
- package/dist/api/customer.d.ts +19 -13
- package/dist/api/customer.mjs +16 -10
- package/dist/api/oauth.cjs +43 -10
- package/dist/api/oauth.d.ts +45 -11
- package/dist/api/oauth.mjs +43 -10
- package/dist/rpc/methods/checkout/checkout.cjs +1 -1
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/types/user.d.ts +1 -1
- package/package.json +1 -1
- /package/dist/api/{README.md → INFO.md} +0 -0
package/CHANGELOG.md
CHANGED
package/dist/api/customer.cjs
CHANGED
|
@@ -61,7 +61,9 @@ class CustomerAPIClient {
|
|
|
61
61
|
throw new _fetch.FetchError(response);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Get the addresses for the current customer
|
|
64
|
+
* Get the addresses for the current customer.
|
|
65
|
+
*
|
|
66
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/address/list-addresses
|
|
65
67
|
*/
|
|
66
68
|
async getAddresses(shopId) {
|
|
67
69
|
return await this.sendRequest(() => fetch(`${this.baseURL}/api/oauth/customer/addresses`, {
|
|
@@ -73,8 +75,9 @@ class CustomerAPIClient {
|
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Returns customer data and latest orders.
|
|
76
|
-
* When not logged in will return undefined
|
|
77
|
-
*
|
|
78
|
+
* When not logged in, it will return `undefined`.
|
|
79
|
+
*
|
|
80
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/get-customer
|
|
78
81
|
*/
|
|
79
82
|
async getMe(shopId, accessToken) {
|
|
80
83
|
return await this.sendRequest(() => fetch(`${this.baseURL}/api/oauth/me`, {
|
|
@@ -88,8 +91,9 @@ class CustomerAPIClient {
|
|
|
88
91
|
}));
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* Retrieve a customer's order.
|
|
95
|
+
*
|
|
96
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/order/get-order
|
|
93
97
|
*/
|
|
94
98
|
async getOrder(shopId, orderId) {
|
|
95
99
|
return this.sendRequest(() => fetch(`${this.baseURL}/api/oauth/customer/order/${orderId}`, {
|
|
@@ -100,9 +104,9 @@ class CustomerAPIClient {
|
|
|
100
104
|
}));
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
103
|
-
* Update
|
|
107
|
+
* Update contact details of a customer.
|
|
104
108
|
*
|
|
105
|
-
* @see https://scayle.dev/api/
|
|
109
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-contact-details
|
|
106
110
|
*/
|
|
107
111
|
async updateContactInfo(shopId, {
|
|
108
112
|
email,
|
|
@@ -121,7 +125,9 @@ class CustomerAPIClient {
|
|
|
121
125
|
}));
|
|
122
126
|
}
|
|
123
127
|
/**
|
|
124
|
-
* Update
|
|
128
|
+
* Update customer personal data.
|
|
129
|
+
*
|
|
130
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-personal-data
|
|
125
131
|
*/
|
|
126
132
|
async updatePersonalInfo(shopId, payload) {
|
|
127
133
|
return await this.sendRequest(() => fetch(`${this.baseURL}/api/oauth/customer/personal`, {
|
|
@@ -134,9 +140,9 @@ class CustomerAPIClient {
|
|
|
134
140
|
}));
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
137
|
-
* Update
|
|
143
|
+
* Update customer password.
|
|
138
144
|
*
|
|
139
|
-
* @see https://scayle.dev/api/
|
|
145
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-password
|
|
140
146
|
*/
|
|
141
147
|
async updatePassword(shopId, {
|
|
142
148
|
password,
|
package/dist/api/customer.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ interface PasswordUpdate {
|
|
|
28
28
|
newPassword: string;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* An API client for interacting with the Checkout Customer API
|
|
31
|
+
* An API client for interacting with the Checkout Customer API.
|
|
32
32
|
*
|
|
33
|
-
* Should be initialized with the token set acquired from the Auth API
|
|
33
|
+
* Should be initialized with the token set acquired from the Auth API.
|
|
34
34
|
*
|
|
35
|
-
* @see https://scayle.dev/api/
|
|
35
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api
|
|
36
36
|
*/
|
|
37
37
|
export declare class CustomerAPIClient {
|
|
38
38
|
baseURL: string;
|
|
@@ -42,34 +42,40 @@ export declare class CustomerAPIClient {
|
|
|
42
42
|
get headers(): HeadersInit;
|
|
43
43
|
sendRequest<BodyType>(request: () => Promise<Response>, retry?: boolean): Promise<BodyType>;
|
|
44
44
|
/**
|
|
45
|
-
* Get the addresses for the current customer
|
|
45
|
+
* Get the addresses for the current customer.
|
|
46
|
+
*
|
|
47
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/address/list-addresses
|
|
46
48
|
*/
|
|
47
49
|
getAddresses(shopId: number): Promise<PaginatedResponse<ShopUserAddress>>;
|
|
48
50
|
/**
|
|
49
51
|
* Returns customer data and latest orders.
|
|
50
|
-
* When not logged in will return undefined
|
|
51
|
-
*
|
|
52
|
+
* When not logged in, it will return `undefined`.
|
|
53
|
+
*
|
|
54
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/get-customer
|
|
52
55
|
*/
|
|
53
56
|
getMe(shopId: number, accessToken?: string): Promise<ShopUser>;
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
58
|
+
* Retrieve a customer's order.
|
|
59
|
+
*
|
|
60
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/order/get-order
|
|
57
61
|
*/
|
|
58
62
|
getOrder(shopId: number, orderId: number): Promise<Order>;
|
|
59
63
|
/**
|
|
60
|
-
* Update
|
|
64
|
+
* Update contact details of a customer.
|
|
61
65
|
*
|
|
62
|
-
* @see https://scayle.dev/api/
|
|
66
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-contact-details
|
|
63
67
|
*/
|
|
64
68
|
updateContactInfo(shopId: number, { email, phone }: Partial<ContactData>): Promise<ShopUser>;
|
|
65
69
|
/**
|
|
66
|
-
* Update
|
|
70
|
+
* Update customer personal data.
|
|
71
|
+
*
|
|
72
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-personal-data
|
|
67
73
|
*/
|
|
68
74
|
updatePersonalInfo(shopId: number, payload: Partial<PersonalData>): Promise<ShopUser>;
|
|
69
75
|
/**
|
|
70
|
-
* Update
|
|
76
|
+
* Update customer password.
|
|
71
77
|
*
|
|
72
|
-
* @see https://scayle.dev/api/
|
|
78
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-password
|
|
73
79
|
*/
|
|
74
80
|
updatePassword(shopId: number, { password, newPassword }: PasswordUpdate): Promise<ShopUser>;
|
|
75
81
|
}
|
package/dist/api/customer.mjs
CHANGED
|
@@ -59,7 +59,9 @@ export class CustomerAPIClient {
|
|
|
59
59
|
throw new FetchError(response);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Get the addresses for the current customer
|
|
62
|
+
* Get the addresses for the current customer.
|
|
63
|
+
*
|
|
64
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/address/list-addresses
|
|
63
65
|
*/
|
|
64
66
|
async getAddresses(shopId) {
|
|
65
67
|
return await this.sendRequest(
|
|
@@ -73,8 +75,9 @@ export class CustomerAPIClient {
|
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Returns customer data and latest orders.
|
|
76
|
-
* When not logged in will return undefined
|
|
77
|
-
*
|
|
78
|
+
* When not logged in, it will return `undefined`.
|
|
79
|
+
*
|
|
80
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/get-customer
|
|
78
81
|
*/
|
|
79
82
|
async getMe(shopId, accessToken) {
|
|
80
83
|
return await this.sendRequest(
|
|
@@ -88,8 +91,9 @@ export class CustomerAPIClient {
|
|
|
88
91
|
);
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* Retrieve a customer's order.
|
|
95
|
+
*
|
|
96
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/order/get-order
|
|
93
97
|
*/
|
|
94
98
|
async getOrder(shopId, orderId) {
|
|
95
99
|
return this.sendRequest(
|
|
@@ -102,9 +106,9 @@ export class CustomerAPIClient {
|
|
|
102
106
|
);
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
105
|
-
* Update
|
|
109
|
+
* Update contact details of a customer.
|
|
106
110
|
*
|
|
107
|
-
* @see https://scayle.dev/api/
|
|
111
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-contact-details
|
|
108
112
|
*/
|
|
109
113
|
async updateContactInfo(shopId, { email, phone }) {
|
|
110
114
|
return await this.sendRequest(
|
|
@@ -122,7 +126,9 @@ export class CustomerAPIClient {
|
|
|
122
126
|
);
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
|
-
* Update
|
|
129
|
+
* Update customer personal data.
|
|
130
|
+
*
|
|
131
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-personal-data
|
|
126
132
|
*/
|
|
127
133
|
async updatePersonalInfo(shopId, payload) {
|
|
128
134
|
return await this.sendRequest(
|
|
@@ -137,9 +143,9 @@ export class CustomerAPIClient {
|
|
|
137
143
|
);
|
|
138
144
|
}
|
|
139
145
|
/**
|
|
140
|
-
* Update
|
|
146
|
+
* Update customer password.
|
|
141
147
|
*
|
|
142
|
-
* @see https://scayle.dev/api/
|
|
148
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/customer/update-password
|
|
143
149
|
*/
|
|
144
150
|
async updatePassword(shopId, { password, newPassword }) {
|
|
145
151
|
return await this.sendRequest(
|
package/dist/api/oauth.cjs
CHANGED
|
@@ -70,8 +70,11 @@ class OAuthClient {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Register a
|
|
73
|
+
* Register a new User and receive an access token.
|
|
74
|
+
*
|
|
74
75
|
* @param payload
|
|
76
|
+
*
|
|
77
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/create-new-user
|
|
75
78
|
*/
|
|
76
79
|
async register(payload) {
|
|
77
80
|
this.logger?.debug("Registering user");
|
|
@@ -82,8 +85,11 @@ class OAuthClient {
|
|
|
82
85
|
}).then(oauthResponseHandler);
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* Login a User and receive an access token.
|
|
89
|
+
*
|
|
86
90
|
* @param payload
|
|
91
|
+
*
|
|
92
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users
|
|
87
93
|
*/
|
|
88
94
|
async login(payload) {
|
|
89
95
|
this.logger?.debug("Logging in");
|
|
@@ -94,8 +100,11 @@ class OAuthClient {
|
|
|
94
100
|
}).then(oauthResponseHandler);
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
103
|
+
* Login a User as a guest and receive an access token.
|
|
104
|
+
*
|
|
98
105
|
* @param payload
|
|
106
|
+
*
|
|
107
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
99
108
|
*/
|
|
100
109
|
async guestLogin(payload) {
|
|
101
110
|
this.logger?.debug("Logging in as guest");
|
|
@@ -106,8 +115,11 @@ class OAuthClient {
|
|
|
106
115
|
}).then(oauthResponseHandler);
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
|
-
* Send a password
|
|
118
|
+
* Send a reset password email to a User.
|
|
119
|
+
*
|
|
110
120
|
* @param payload
|
|
121
|
+
*
|
|
122
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/send-password-reset-email
|
|
111
123
|
*/
|
|
112
124
|
async sendPasswordResetEmail(payload) {
|
|
113
125
|
this.logger?.debug("Sending password reset email");
|
|
@@ -118,8 +130,12 @@ class OAuthClient {
|
|
|
118
130
|
}).then(emptyOAuthResponseHandler);
|
|
119
131
|
}
|
|
120
132
|
/**
|
|
121
|
-
* Update password by hash
|
|
133
|
+
* Update password by using hash.
|
|
134
|
+
* All older tokens of the User are also invalidated.
|
|
135
|
+
*
|
|
122
136
|
* @param payload
|
|
137
|
+
*
|
|
138
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/update-password-by-hash
|
|
123
139
|
*/
|
|
124
140
|
async updatePasswordByHash(payload) {
|
|
125
141
|
this.logger?.debug("Updating password by hash");
|
|
@@ -130,7 +146,8 @@ class OAuthClient {
|
|
|
130
146
|
}).then(oauthResponseHandler);
|
|
131
147
|
}
|
|
132
148
|
/**
|
|
133
|
-
* Update
|
|
149
|
+
* Update password via plain string.
|
|
150
|
+
*
|
|
134
151
|
* @param payload
|
|
135
152
|
* @param accessToken
|
|
136
153
|
*/
|
|
@@ -146,7 +163,8 @@ class OAuthClient {
|
|
|
146
163
|
}).then(emptyOAuthResponseHandler);
|
|
147
164
|
}
|
|
148
165
|
/**
|
|
149
|
-
* Generate a new access token via a refresh token
|
|
166
|
+
* Generate a new access token via a refresh token.
|
|
167
|
+
*
|
|
150
168
|
* @param payload
|
|
151
169
|
*/
|
|
152
170
|
async refreshToken(payload) {
|
|
@@ -158,8 +176,11 @@ class OAuthClient {
|
|
|
158
176
|
}).then(oauthResponseHandler);
|
|
159
177
|
}
|
|
160
178
|
/**
|
|
161
|
-
* Validate
|
|
179
|
+
* Validate a token.
|
|
180
|
+
*
|
|
162
181
|
* @param accessToken
|
|
182
|
+
*
|
|
183
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/validate-present-token
|
|
163
184
|
*/
|
|
164
185
|
async validateToken(accessToken) {
|
|
165
186
|
this.logger?.debug("Validating access token");
|
|
@@ -171,9 +192,20 @@ class OAuthClient {
|
|
|
171
192
|
}).then(emptyOAuthResponseHandler);
|
|
172
193
|
}
|
|
173
194
|
/**
|
|
174
|
-
* Revoke an
|
|
195
|
+
* Revoke an Access Token and all related Refresh Tokens.
|
|
196
|
+
*
|
|
197
|
+
* Uses a valid Bearer Access Token in the Authorization header and will
|
|
198
|
+
* revoke the token with the given ID (_which could be a different token_).
|
|
199
|
+
* If a external identity provider was used for the target token,
|
|
200
|
+
* the corresponding IDP-AccessToken and IDP-RefreshToken will be revoked as well.
|
|
201
|
+
* In case the identity provider does not support revoking tokens over api calls
|
|
202
|
+
* (_because a frontend redirect is required_) this step will be skipped and the IDP-Tokens
|
|
203
|
+
* will remain valid until they expire or are revoked from IDP side.
|
|
204
|
+
*
|
|
175
205
|
* @param shopId
|
|
176
206
|
* @param accessToken
|
|
207
|
+
*
|
|
208
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/delete-access-token-with-id
|
|
177
209
|
*/
|
|
178
210
|
async revokeToken(shopId, accessToken) {
|
|
179
211
|
this.logger?.debug("Revoking access token");
|
|
@@ -188,7 +220,8 @@ class OAuthClient {
|
|
|
188
220
|
}).then(emptyOAuthResponseHandler);
|
|
189
221
|
}
|
|
190
222
|
/**
|
|
191
|
-
* Generate a new token based on authorization code
|
|
223
|
+
* Generate a new token based on authorization code.
|
|
224
|
+
*
|
|
192
225
|
* @param code
|
|
193
226
|
*/
|
|
194
227
|
async generateToken(code) {
|
package/dist/api/oauth.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export interface OAuthOptions {
|
|
|
10
10
|
export declare function getOAuthClient(context: RpcContext): OAuthClient;
|
|
11
11
|
/**
|
|
12
12
|
* A client for interacting with the Checkout Authentication API
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api
|
|
14
15
|
*/
|
|
15
16
|
export declare class OAuthClient {
|
|
16
17
|
headers: HeadersInit;
|
|
@@ -19,54 +20,87 @@ export declare class OAuthClient {
|
|
|
19
20
|
clientId: string;
|
|
20
21
|
constructor(options: OAuthOptions, logger?: Log);
|
|
21
22
|
/**
|
|
22
|
-
* Register a
|
|
23
|
+
* Register a new User and receive an access token.
|
|
24
|
+
*
|
|
23
25
|
* @param payload
|
|
26
|
+
*
|
|
27
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/create-new-user
|
|
24
28
|
*/
|
|
25
29
|
register(payload: RegisterRequest): Promise<Oauth>;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Login a User and receive an access token.
|
|
32
|
+
*
|
|
28
33
|
* @param payload
|
|
34
|
+
*
|
|
35
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users
|
|
29
36
|
*/
|
|
30
37
|
login(payload: LoginRequest): Promise<Oauth>;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Login a User as a guest and receive an access token.
|
|
40
|
+
*
|
|
33
41
|
* @param payload
|
|
42
|
+
*
|
|
43
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
34
44
|
*/
|
|
35
45
|
guestLogin(payload: GuestRequest): Promise<Oauth>;
|
|
36
46
|
/**
|
|
37
|
-
* Send a password
|
|
47
|
+
* Send a reset password email to a User.
|
|
48
|
+
*
|
|
38
49
|
* @param payload
|
|
50
|
+
*
|
|
51
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/send-password-reset-email
|
|
39
52
|
*/
|
|
40
53
|
sendPasswordResetEmail(payload: SendResetPasswordEmailRequest): Promise<void>;
|
|
41
54
|
/**
|
|
42
|
-
* Update password by hash
|
|
55
|
+
* Update password by using hash.
|
|
56
|
+
* All older tokens of the User are also invalidated.
|
|
57
|
+
*
|
|
43
58
|
* @param payload
|
|
59
|
+
*
|
|
60
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/update-password-by-hash
|
|
44
61
|
*/
|
|
45
62
|
updatePasswordByHash(payload: UpdatePasswordByHashRequest): Promise<Oauth>;
|
|
46
63
|
/**
|
|
47
|
-
* Update
|
|
64
|
+
* Update password via plain string.
|
|
65
|
+
*
|
|
48
66
|
* @param payload
|
|
49
67
|
* @param accessToken
|
|
50
68
|
*/
|
|
51
69
|
updatePassword(payload: UpdatePasswordRequest, accessToken: string): Promise<void>;
|
|
52
70
|
/**
|
|
53
|
-
* Generate a new access token via a refresh token
|
|
71
|
+
* Generate a new access token via a refresh token.
|
|
72
|
+
*
|
|
54
73
|
* @param payload
|
|
55
74
|
*/
|
|
56
75
|
refreshToken(payload: RefreshTokenRequest): Promise<Oauth>;
|
|
57
76
|
/**
|
|
58
|
-
* Validate
|
|
77
|
+
* Validate a token.
|
|
78
|
+
*
|
|
59
79
|
* @param accessToken
|
|
80
|
+
*
|
|
81
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/validate-present-token
|
|
60
82
|
*/
|
|
61
83
|
validateToken(accessToken: string): Promise<void>;
|
|
62
84
|
/**
|
|
63
|
-
* Revoke an
|
|
85
|
+
* Revoke an Access Token and all related Refresh Tokens.
|
|
86
|
+
*
|
|
87
|
+
* Uses a valid Bearer Access Token in the Authorization header and will
|
|
88
|
+
* revoke the token with the given ID (_which could be a different token_).
|
|
89
|
+
* If a external identity provider was used for the target token,
|
|
90
|
+
* the corresponding IDP-AccessToken and IDP-RefreshToken will be revoked as well.
|
|
91
|
+
* In case the identity provider does not support revoking tokens over api calls
|
|
92
|
+
* (_because a frontend redirect is required_) this step will be skipped and the IDP-Tokens
|
|
93
|
+
* will remain valid until they expire or are revoked from IDP side.
|
|
94
|
+
*
|
|
64
95
|
* @param shopId
|
|
65
96
|
* @param accessToken
|
|
97
|
+
*
|
|
98
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/delete-access-token-with-id
|
|
66
99
|
*/
|
|
67
100
|
revokeToken(shopId: number, accessToken: string): Promise<void>;
|
|
68
101
|
/**
|
|
69
|
-
* Generate a new token based on authorization code
|
|
102
|
+
* Generate a new token based on authorization code.
|
|
103
|
+
*
|
|
70
104
|
* @param code
|
|
71
105
|
*/
|
|
72
106
|
generateToken(code: string): Promise<Oauth>;
|
package/dist/api/oauth.mjs
CHANGED
|
@@ -56,8 +56,11 @@ export class OAuthClient {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Register a
|
|
59
|
+
* Register a new User and receive an access token.
|
|
60
|
+
*
|
|
60
61
|
* @param payload
|
|
62
|
+
*
|
|
63
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/create-new-user
|
|
61
64
|
*/
|
|
62
65
|
async register(payload) {
|
|
63
66
|
this.logger?.debug("Registering user");
|
|
@@ -68,8 +71,11 @@ export class OAuthClient {
|
|
|
68
71
|
}).then(oauthResponseHandler);
|
|
69
72
|
}
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* Login a User and receive an access token.
|
|
75
|
+
*
|
|
72
76
|
* @param payload
|
|
77
|
+
*
|
|
78
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users
|
|
73
79
|
*/
|
|
74
80
|
async login(payload) {
|
|
75
81
|
this.logger?.debug("Logging in");
|
|
@@ -80,8 +86,11 @@ export class OAuthClient {
|
|
|
80
86
|
}).then(oauthResponseHandler);
|
|
81
87
|
}
|
|
82
88
|
/**
|
|
83
|
-
*
|
|
89
|
+
* Login a User as a guest and receive an access token.
|
|
90
|
+
*
|
|
84
91
|
* @param payload
|
|
92
|
+
*
|
|
93
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
85
94
|
*/
|
|
86
95
|
async guestLogin(payload) {
|
|
87
96
|
this.logger?.debug("Logging in as guest");
|
|
@@ -92,8 +101,11 @@ export class OAuthClient {
|
|
|
92
101
|
}).then(oauthResponseHandler);
|
|
93
102
|
}
|
|
94
103
|
/**
|
|
95
|
-
* Send a password
|
|
104
|
+
* Send a reset password email to a User.
|
|
105
|
+
*
|
|
96
106
|
* @param payload
|
|
107
|
+
*
|
|
108
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/send-password-reset-email
|
|
97
109
|
*/
|
|
98
110
|
async sendPasswordResetEmail(payload) {
|
|
99
111
|
this.logger?.debug("Sending password reset email");
|
|
@@ -104,8 +116,12 @@ export class OAuthClient {
|
|
|
104
116
|
}).then(emptyOAuthResponseHandler);
|
|
105
117
|
}
|
|
106
118
|
/**
|
|
107
|
-
* Update password by hash
|
|
119
|
+
* Update password by using hash.
|
|
120
|
+
* All older tokens of the User are also invalidated.
|
|
121
|
+
*
|
|
108
122
|
* @param payload
|
|
123
|
+
*
|
|
124
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/oauth-client/update-password-by-hash
|
|
109
125
|
*/
|
|
110
126
|
async updatePasswordByHash(payload) {
|
|
111
127
|
this.logger?.debug("Updating password by hash");
|
|
@@ -116,7 +132,8 @@ export class OAuthClient {
|
|
|
116
132
|
}).then(oauthResponseHandler);
|
|
117
133
|
}
|
|
118
134
|
/**
|
|
119
|
-
* Update
|
|
135
|
+
* Update password via plain string.
|
|
136
|
+
*
|
|
120
137
|
* @param payload
|
|
121
138
|
* @param accessToken
|
|
122
139
|
*/
|
|
@@ -132,7 +149,8 @@ export class OAuthClient {
|
|
|
132
149
|
}).then(emptyOAuthResponseHandler);
|
|
133
150
|
}
|
|
134
151
|
/**
|
|
135
|
-
* Generate a new access token via a refresh token
|
|
152
|
+
* Generate a new access token via a refresh token.
|
|
153
|
+
*
|
|
136
154
|
* @param payload
|
|
137
155
|
*/
|
|
138
156
|
async refreshToken(payload) {
|
|
@@ -144,8 +162,11 @@ export class OAuthClient {
|
|
|
144
162
|
}).then(oauthResponseHandler);
|
|
145
163
|
}
|
|
146
164
|
/**
|
|
147
|
-
* Validate
|
|
165
|
+
* Validate a token.
|
|
166
|
+
*
|
|
148
167
|
* @param accessToken
|
|
168
|
+
*
|
|
169
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/validate-present-token
|
|
149
170
|
*/
|
|
150
171
|
async validateToken(accessToken) {
|
|
151
172
|
this.logger?.debug("Validating access token");
|
|
@@ -157,9 +178,20 @@ export class OAuthClient {
|
|
|
157
178
|
}).then(emptyOAuthResponseHandler);
|
|
158
179
|
}
|
|
159
180
|
/**
|
|
160
|
-
* Revoke an
|
|
181
|
+
* Revoke an Access Token and all related Refresh Tokens.
|
|
182
|
+
*
|
|
183
|
+
* Uses a valid Bearer Access Token in the Authorization header and will
|
|
184
|
+
* revoke the token with the given ID (_which could be a different token_).
|
|
185
|
+
* If a external identity provider was used for the target token,
|
|
186
|
+
* the corresponding IDP-AccessToken and IDP-RefreshToken will be revoked as well.
|
|
187
|
+
* In case the identity provider does not support revoking tokens over api calls
|
|
188
|
+
* (_because a frontend redirect is required_) this step will be skipped and the IDP-Tokens
|
|
189
|
+
* will remain valid until they expire or are revoked from IDP side.
|
|
190
|
+
*
|
|
161
191
|
* @param shopId
|
|
162
192
|
* @param accessToken
|
|
193
|
+
*
|
|
194
|
+
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/resources/bearer-auth/delete-access-token-with-id
|
|
163
195
|
*/
|
|
164
196
|
async revokeToken(shopId, accessToken) {
|
|
165
197
|
this.logger?.debug("Revoking access token");
|
|
@@ -174,7 +206,8 @@ export class OAuthClient {
|
|
|
174
206
|
}).then(emptyOAuthResponseHandler);
|
|
175
207
|
}
|
|
176
208
|
/**
|
|
177
|
-
* Generate a new token based on authorization code
|
|
209
|
+
* Generate a new token based on authorization code.
|
|
210
|
+
*
|
|
178
211
|
* @param code
|
|
179
212
|
*/
|
|
180
213
|
async generateToken(code) {
|
|
@@ -37,7 +37,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
|
|
|
37
37
|
carrier,
|
|
38
38
|
basketId: context.basketKey,
|
|
39
39
|
campaignKey: context.campaignKey
|
|
40
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
40
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.4.0"}`).setProtectedHeader({
|
|
41
41
|
alg: "HS256",
|
|
42
42
|
typ: "JWT"
|
|
43
43
|
}).sign(secret);
|
|
@@ -35,7 +35,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
35
35
|
carrier,
|
|
36
36
|
basketId: context.basketKey,
|
|
37
37
|
campaignKey: context.campaignKey
|
|
38
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
38
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.4.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
39
39
|
return {
|
|
40
40
|
accessToken: refreshedAccessToken,
|
|
41
41
|
checkoutJwt
|
package/dist/types/user.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UseBasketParams } from './sapi/basket';
|
|
2
2
|
import type { UseWishlistParams } from './sapi/wishlist';
|
|
3
|
-
export type Gender = 'm' | 'f' | 'd';
|
|
3
|
+
export type Gender = 'm' | 'f' | 'd' | 'n';
|
|
4
4
|
export interface UpdatePasswordParams {
|
|
5
5
|
oldPassword: string;
|
|
6
6
|
newPassword: string;
|
package/package.json
CHANGED
|
File without changes
|