Skip to content

Commit c222f98

Browse files
committed
"isSession" field added to the "UpdateCustomerInput" type
1 parent 36e79d3 commit c222f98

File tree

8 files changed

+78
-82
lines changed

8 files changed

+78
-82
lines changed

bin/_lib.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ install_wordpress() {
3535
composer require --dev --no-interaction -W \
3636
johnpbloch/wordpress:* \
3737
wp-graphql/wp-graphql-jwt-authentication \
38-
axepress/wp-graphql-headless-login \
3938
wpackagist-plugin/woocommerce \
4039
wpackagist-plugin/woocommerce-gateway-stripe \
4140
wpackagist-plugin/wp-graphql \
@@ -51,7 +50,6 @@ remove_wordpress() {
5150

5251
# Remove WordPress dependencies
5352
composer remove --dev wp-graphql/wp-graphql-jwt-authentication \
54-
axepress/wp-graphql-headless-login \
5553
wpackagist-plugin/woocommerce-gateway-stripe \
5654
wpackagist-plugin/wp-graphql \
5755
wpackagist-theme/twentytwentyone \

composer.lock

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/model/class-customer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ class Customer extends Model {
4747
* Customer constructor
4848
*
4949
* @param \WC_Customer|int|string $id - User ID.
50+
* @param bool $is_session - Whether the customer is a session.
5051
*/
51-
public function __construct( $id = 'session' ) {
52-
$this->data = 'session' === $id ? \WC()->customer : new WC_Customer( absint( $id ) );
52+
public function __construct( $id = 'session', $is_session = false ) {
53+
$this->data = 'session' === $id ? \WC()->customer : new WC_Customer( absint( $id ), $is_session );
5354
$allowed_restricted_fields = [
5455
'isRestricted',
5556
'isPrivate',

includes/mutation/class-customer-update.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public static function get_input_fields() {
6666
'description' => __( 'Meta data.', 'wp-graphql-woocommerce' ),
6767
'type' => [ 'list_of' => 'MetaDataInput' ],
6868
],
69+
'isSession' => [
70+
'type' => 'Boolean',
71+
'description' => __( 'Whether to save changes on the session or in the database', 'wp-graphql-woocommerce' ),
72+
],
6973
]
7074
);
7175
}
@@ -93,6 +97,7 @@ public static function get_output_fields() {
9397
*/
9498
public static function mutate_and_get_payload() {
9599
return static function ( $input, AppContext $context, ResolveInfo $info ) {
100+
$is_session = isset( $input['isSession'] ) ? $input['isSession'] : false;
96101
$session_only = empty( $input['id'] ) && ! is_user_logged_in();
97102
$payload = null;
98103

@@ -116,7 +121,7 @@ public static function mutate_and_get_payload() {
116121
$customer_args = Customer_Mutation::prepare_customer_props( $input, 'update' );
117122

118123
// Create customer object.
119-
$customer = ! $session_only ? new WC_Customer( $payload['id'] ) : \WC()->customer;
124+
$customer = ! $session_only ? new WC_Customer( $payload['id'], $is_session ) : \WC()->customer;
120125

121126
// Copy billing address as shipping address.
122127
if ( isset( $input['shippingSameAsBilling'] ) && $input['shippingSameAsBilling'] ) {

vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public function __construct(
8686
ClientInterface $httpClient,
8787
RequestFactoryInterface $httpFactory,
8888
CacheItemPoolInterface $cache,
89-
int $expiresAfter = null,
89+
?int $expiresAfter = null,
9090
bool $rateLimit = false,
91-
string $defaultAlg = null
91+
?string $defaultAlg = null
9292
) {
9393
$this->jwksUri = $jwksUri;
9494
$this->httpClient = $httpClient;
@@ -186,7 +186,7 @@ private function keyIdExists(string $keyId): bool
186186
$jwksResponse = $this->httpClient->sendRequest($request);
187187
if ($jwksResponse->getStatusCode() !== 200) {
188188
throw new UnexpectedValueException(
189-
sprintf('HTTP Error: %d %s for URI "%s"',
189+
\sprintf('HTTP Error: %d %s for URI "%s"',
190190
$jwksResponse->getStatusCode(),
191191
$jwksResponse->getReasonPhrase(),
192192
$this->jwksUri,

vendor-prefixed/firebase/php-jwt/src/JWK.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class JWK
5858
*
5959
* @uses parseKey
6060
*/
61-
public static function parseKeySet(array $jwks, string $defaultAlg = null): array
61+
public static function parseKeySet(array $jwks, ?string $defaultAlg = null): array
6262
{
6363
$keys = [];
6464

@@ -99,7 +99,7 @@ public static function parseKeySet(array $jwks, string $defaultAlg = null): arra
9999
*
100100
* @uses createPemFromModulusAndExponent
101101
*/
102-
public static function parseKey(array $jwk, string $defaultAlg = null): ?Key
102+
public static function parseKey(array $jwk, ?string $defaultAlg = null): ?Key
103103
{
104104
if (empty($jwk)) {
105105
throw new InvalidArgumentException('JWK must not be empty');
@@ -178,6 +178,12 @@ public static function parseKey(array $jwk, string $defaultAlg = null): ?Key
178178
// This library works internally with EdDSA keys (Ed25519) encoded in standard base64.
179179
$publicKey = JWT::convertBase64urlToBase64($jwk['x']);
180180
return new Key($publicKey, $jwk['alg']);
181+
case 'oct':
182+
if (!isset($jwk['k'])) {
183+
throw new UnexpectedValueException('k not set');
184+
}
185+
186+
return new Key(JWT::urlsafeB64Decode($jwk['k']), $jwk['alg']);
181187
default:
182188
break;
183189
}
@@ -218,7 +224,7 @@ private static function createPemFromCrvAndXYCoordinates(string $crv, string $x,
218224
)
219225
);
220226

221-
return sprintf(
227+
return \sprintf(
222228
"-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----\n",
223229
wordwrap(base64_encode($pem), 64, "\n", true)
224230
);

0 commit comments

Comments
 (0)