@shop-on/customer-runtime 0.3.0 → 0.5.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/dist/handoff-state.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//#region src/handoff-state.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Shared rules for the states that bind a handoff to the browser that started
|
|
4
|
-
* it, used by their minters
|
|
5
|
-
*
|
|
6
|
-
* consumer verifies the value against its own cookie.
|
|
4
|
+
* it, used by their minters and their checkers. The formats are a shape check
|
|
5
|
+
* only: each consumer verifies the value against its own cookie.
|
|
7
6
|
*
|
|
8
7
|
* - `checkout_state`: `ts "." base64url(HMAC-SHA256)`, minted by checkout's
|
|
9
|
-
* `/begin
|
|
8
|
+
* `/begin`, carried by the theme onto the cart handoff URL.
|
|
10
9
|
* - `state` (theme): 32 random bytes base64url, minted by theme-server's
|
|
11
|
-
* `account_state` cookie
|
|
10
|
+
* `account_state` cookie; the account `return_to` sanitizer passes it
|
|
11
|
+
* through on storefront hosts.
|
|
12
12
|
*/
|
|
13
13
|
export declare const CHECKOUT_STATE_FORMAT: RegExp;
|
|
14
14
|
export declare const ACCOUNT_STATE_FORMAT: RegExp;
|
package/dist/handoff-state.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//#region src/handoff-state.ts
|
|
2
2
|
/**
|
|
3
3
|
* Shared rules for the states that bind a handoff to the browser that started
|
|
4
|
-
* it, used by their minters
|
|
5
|
-
*
|
|
6
|
-
* consumer verifies the value against its own cookie.
|
|
4
|
+
* it, used by their minters and their checkers. The formats are a shape check
|
|
5
|
+
* only: each consumer verifies the value against its own cookie.
|
|
7
6
|
*
|
|
8
7
|
* - `checkout_state`: `ts "." base64url(HMAC-SHA256)`, minted by checkout's
|
|
9
|
-
* `/begin
|
|
8
|
+
* `/begin`, carried by the theme onto the cart handoff URL.
|
|
10
9
|
* - `state` (theme): 32 random bytes base64url, minted by theme-server's
|
|
11
|
-
* `account_state` cookie
|
|
10
|
+
* `account_state` cookie; the account `return_to` sanitizer passes it
|
|
11
|
+
* through on storefront hosts.
|
|
12
12
|
*/
|
|
13
13
|
const CHECKOUT_STATE_FORMAT = /^\d{10}\.[A-Za-z0-9_-]{43}$/;
|
|
14
14
|
const ACCOUNT_STATE_FORMAT = /^[A-Za-z0-9_-]{43}$/;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/storefront-bounce.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The storefront's own `/account` bounce, coming back to `returnToPath`.
|
|
4
|
+
* Account and checkout sign a buyer in through it rather than linking to
|
|
5
|
+
* account directly: the theme issues the `state` its customer handoff is
|
|
6
|
+
* bound to, bounces to account, and consumes the handoff on the way back.
|
|
7
|
+
* Pure, so either app can build the link in a component.
|
|
8
|
+
*/
|
|
9
|
+
export declare function storefrontAccountBounceUrl(storefrontRoot: string, returnToPath: string): string;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/storefront-bounce.ts
|
|
2
|
+
/**
|
|
3
|
+
* The storefront's own `/account` bounce, coming back to `returnToPath`.
|
|
4
|
+
* Account and checkout sign a buyer in through it rather than linking to
|
|
5
|
+
* account directly: the theme issues the `state` its customer handoff is
|
|
6
|
+
* bound to, bounces to account, and consumes the handoff on the way back.
|
|
7
|
+
* Pure, so either app can build the link in a component.
|
|
8
|
+
*/
|
|
9
|
+
function storefrontAccountBounceUrl(storefrontRoot, returnToPath) {
|
|
10
|
+
const url = new URL("/account", storefrontRoot);
|
|
11
|
+
url.searchParams.set("return_to", returnToPath);
|
|
12
|
+
return url.toString();
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { storefrontAccountBounceUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shop-on/customer-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "SEE LICENSE IN dist/LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./sealed-session": "./dist/sealed-session.js",
|
|
19
19
|
"./session-cookie": "./dist/session-cookie.js",
|
|
20
20
|
"./shop-context": "./dist/shop-context.js",
|
|
21
|
+
"./storefront-bounce": "./dist/storefront-bounce.js",
|
|
21
22
|
"./trace": "./dist/trace.js",
|
|
22
23
|
"./package.json": "./package.json"
|
|
23
24
|
},
|