Skip to content

Commit 8dff369

Browse files
authored
Merge branch 'main' into ash/update-account-kit-react-hook-docs
2 parents 05c8356 + a7cbb95 commit 8dff369

37 files changed

+227
-78
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
### Bug Fixes
9+
10+
- change twitter display name in demo app ([#1311](https://github.com/alchemyplatform/aa-sdk/issues/1311)) ([22fb32b](https://github.com/alchemyplatform/aa-sdk/commit/22fb32b95278f572b310bab8caa1a6a7b2a5d3ee))
11+
- clean up / refactor demo app ([#1301](https://github.com/alchemyplatform/aa-sdk/issues/1301)) ([4c3956c](https://github.com/alchemyplatform/aa-sdk/commit/4c3956c01ce5ae3c157f006bf58fffde758e5d1b))
12+
13+
### Features
14+
15+
- session expiration improvements ([#1291](https://github.com/alchemyplatform/aa-sdk/issues/1291)) ([7cc7b33](https://github.com/alchemyplatform/aa-sdk/commit/7cc7b3371c2d8695ef0ccf34586d8f5079782953))
16+
617
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
718

819
### Features

aa-sdk/core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
**Note:** Version bump only for package @aa-sdk/core
9+
610
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
711

812
**Note:** Version bump only for package @aa-sdk/core

aa-sdk/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@aa-sdk/core",
33
"license": "MIT",
4-
"version": "4.11.0",
4+
"version": "4.12.0",
55
"description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
66
"author": "Alchemy",
77
"type": "module",

aa-sdk/core/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is autogenerated by inject-version.ts. Any changes will be
22
// overwritten on commit!
3-
export const VERSION = "4.11.0";
3+
export const VERSION = "4.12.0";

aa-sdk/ethers/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
**Note:** Version bump only for package @aa-sdk/ethers
9+
610
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
711

812
**Note:** Version bump only for package @aa-sdk/ethers

aa-sdk/ethers/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@aa-sdk/ethers",
33
"license": "MIT",
4-
"version": "4.11.0",
4+
"version": "4.12.0",
55
"description": "Ethers.js wrapper for @aa-sdk/core",
66
"author": "Alchemy",
77
"type": "module",
@@ -42,15 +42,15 @@
4242
"test:run": "vitest run"
4343
},
4444
"devDependencies": {
45-
"@account-kit/smart-contracts": "^4.11.0",
45+
"@account-kit/smart-contracts": "^4.12.0",
4646
"alchemy-sdk": "^3.0.0",
4747
"dotenv": "^16.0.3",
4848
"typescript": "^5.0.4",
4949
"typescript-template": "*",
5050
"vitest": "^2.0.4"
5151
},
5252
"dependencies": {
53-
"@aa-sdk/core": "^4.11.0",
53+
"@aa-sdk/core": "^4.12.0",
5454
"@ethersproject/abi": "^5.7.0",
5555
"@ethersproject/abstract-signer": "^5.7.0",
5656
"@ethersproject/bytes": "^5.7.0",

account-kit/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
### Features
9+
10+
- session expiration improvements ([#1291](https://github.com/alchemyplatform/aa-sdk/issues/1291)) ([7cc7b33](https://github.com/alchemyplatform/aa-sdk/commit/7cc7b3371c2d8695ef0ccf34586d8f5079782953))
11+
612
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
713

814
**Note:** Version bump only for package @account-kit/core

account-kit/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@account-kit/core",
3-
"version": "4.11.0",
3+
"version": "4.12.0",
44
"description": "Core library for account kit that provides state management and framework indepednent abstractions across infra, Alchemy Signer, and Smart Contracts",
55
"author": "Alchemy",
66
"license": "MIT",
@@ -46,10 +46,10 @@
4646
"vitest": "^2.0.4"
4747
},
4848
"dependencies": {
49-
"@account-kit/infra": "^4.11.0",
50-
"@account-kit/logging": "^4.11.0",
51-
"@account-kit/signer": "^4.11.0",
52-
"@account-kit/smart-contracts": "^4.11.0",
49+
"@account-kit/infra": "^4.12.0",
50+
"@account-kit/logging": "^4.12.0",
51+
"@account-kit/signer": "^4.12.0",
52+
"@account-kit/smart-contracts": "^4.12.0",
5353
"js-cookie": "^3.0.5",
5454
"zod": "^3.22.4",
5555
"zustand": "^5.0.0-rc.2"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { alchemy, sepolia } from "@account-kit/infra";
2+
import { createConfig } from "./createConfig.js";
3+
4+
describe("createConfig", () => {
5+
it("should set the internal session length", async () => {
6+
const config = await givenConfig();
7+
expect(config._internal.sessionLength).toBe(5000);
8+
});
9+
10+
it("should set the session config expiration time", async () => {
11+
const config = await givenConfig();
12+
expect(config.store.getState().config.sessionConfig?.expirationTimeMs).toBe(
13+
5000
14+
);
15+
});
16+
17+
const givenConfig = async () => {
18+
return createConfig({
19+
chain: sepolia,
20+
transport: alchemy({ rpcUrl: "/api/sepolia" }),
21+
signerConnection: { rpcUrl: "/api/signer" },
22+
storage: () => localStorage,
23+
sessionConfig: {
24+
expirationTimeMs: 5000,
25+
},
26+
});
27+
};
28+
});

account-kit/core/src/createConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export const createConfig = (
8787
storage: storage?.(
8888
sessionConfig
8989
? {
90-
sessionLength: sessionConfig.expirationTimeMs,
9190
domain: sessionConfig.domain,
9291
}
9392
: undefined

account-kit/core/src/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ type RpcConnectionConfig =
9494
chains?: never;
9595
};
9696

97+
type CreateStorageFn = (config?: {
98+
/** @deprecated Use `sessionConfig` to define session length instead. */
99+
sessionLength?: number;
100+
domain?: string;
101+
}) => Storage;
102+
97103
export type CreateConfigProps = RpcConnectionConfig & {
98104
sessionConfig?: AlchemySignerParams["sessionConfig"] & { domain?: string };
99105
/**
@@ -102,8 +108,7 @@ export type CreateConfigProps = RpcConnectionConfig & {
102108
*/
103109
ssr?: boolean;
104110

105-
// TODO: should probably abstract this out into a function
106-
storage?: (config?: { sessionLength?: number; domain?: string }) => Storage;
111+
storage?: CreateStorageFn;
107112

108113
connectors?: CreateConnectorFn[];
109114

account-kit/core/src/utils/cookies.ts

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,70 @@
1-
import { DEFAULT_SESSION_MS } from "@account-kit/signer";
21
import { cookieToInitialState as wagmiCookieToInitialState } from "@wagmi/core";
32
import Cookies from "js-cookie";
43
import type { StoredState } from "../store/types.js";
54
import type { AlchemyAccountsConfig } from "../types.js";
65
import { deserialize } from "./deserialize.js";
76

7+
// The maximum duration of a cookie according to the spec is 400 days.
8+
// https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-cookie-lifetime-limits
9+
const MAX_COOKIE_DURATION_MS = 1000 * 60 * 60 * 24 * 400;
10+
811
/**
912
* Function to create cookie based Storage
1013
*
11-
* @param {{sessionLength: number; domain?: string}} config optional config object that allows you to set the session length
12-
* @param {number} config.sessionLength the length of the session in milliseconds
14+
* @param {{sessionLength: number; domain?: string}} config optional config object
15+
* @param {number} config.sessionLength the duration until the cookie expires in milliseconds (deprecated)
1316
* @param {string} config.domain optional domain to set the cookie on, eg: `example.com` if you want the cookie to work on all subdomains of example.com
1417
* @returns {Storage} an instance of a browser storage object that leverages cookies
1518
*/
1619
export const cookieStorage = (config?: {
20+
/** @deprecated this option is deprecated and will be ignored */
1721
sessionLength?: number;
1822
domain?: string;
19-
}): Storage => ({
20-
// this is unused for now, we should update this if we do need it
21-
length: 0,
22-
23-
clear: function (): void {
24-
throw new Error(
25-
"clearing cookies is not supported as this could lead to unexpected behaviour.\n" +
26-
" Use removeItem instead or you can manually clear cookies with document.cookie = ''"
23+
}): Storage => {
24+
if (config?.sessionLength) {
25+
console.warn(
26+
"The cookieStorage sessionLength option is deprecated and will be ignored."
2727
);
28-
},
28+
}
29+
return {
30+
// this is unused for now, we should update this if we do need it
31+
length: 0,
32+
33+
clear: function (): void {
34+
throw new Error(
35+
"clearing cookies is not supported as this could lead to unexpected behaviour.\n" +
36+
" Use removeItem instead or you can manually clear cookies with document.cookie = ''"
37+
);
38+
},
2939

30-
getItem: function (key: string): string | null {
31-
if (typeof document === "undefined") return null;
40+
getItem: function (key: string): string | null {
41+
if (typeof document === "undefined") return null;
3242

33-
const cookieValue = Cookies.get(key);
34-
return cookieValue ? decodeURIComponent(cookieValue) : null;
35-
},
43+
const cookieValue = Cookies.get(key);
44+
return cookieValue ? decodeURIComponent(cookieValue) : null;
45+
},
3646

37-
// we will not be using this, if we have need for it add it back later
38-
key: function (): string | null {
39-
throw new Error("Function not implemented.");
40-
},
47+
// we will not be using this, if we have need for it add it back later
48+
key: function (): string | null {
49+
throw new Error("Function not implemented.");
50+
},
4151

42-
removeItem: function (key: string): void {
43-
if (typeof document === "undefined") return;
52+
removeItem: function (key: string): void {
53+
if (typeof document === "undefined") return;
4454

45-
Cookies.remove(key);
46-
},
55+
Cookies.remove(key);
56+
},
4757

48-
setItem: function (key: string, value: string): void {
49-
if (typeof document === "undefined") return;
58+
setItem: function (key: string, value: string): void {
59+
if (typeof document === "undefined") return;
5060

51-
Cookies.set(key, value, {
52-
expires: new Date(
53-
Date.now() + (config?.sessionLength ?? DEFAULT_SESSION_MS)
54-
),
55-
domain: config?.domain,
56-
});
57-
},
58-
});
61+
Cookies.set(key, value, {
62+
expires: new Date(Date.now() + MAX_COOKIE_DURATION_MS),
63+
domain: config?.domain,
64+
});
65+
},
66+
};
67+
};
5968

6069
/**
6170
* Converts a cookie into an initial state object
@@ -77,6 +86,17 @@ export function cookieToInitialState(
7786
state: StoredState["alchemy"];
7887
}>(state).state;
7988

89+
// If the expirationTimeMs is changed in the config, we should use the new config
90+
// value instead of restoring the value from the cookie, otherwise it can lead
91+
// to confusion and unexpected behavior when it seems like the expirationTimeMs
92+
// is being ignored.
93+
alchemyClientState.config.sessionConfig = {
94+
...alchemyClientState.config.sessionConfig,
95+
expirationTimeMs:
96+
config.store.getInitialState().config.sessionConfig?.expirationTimeMs ??
97+
alchemyClientState.config.sessionConfig?.expirationTimeMs,
98+
};
99+
80100
const wagmiClientState = wagmiCookieToInitialState(
81101
config._internal.wagmiConfig,
82102
decodeURIComponent(cookie)

account-kit/core/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is autogenerated by inject-version.ts. Any changes will be
22
// overwritten on commit!
3-
export const VERSION = "4.11.0";
3+
export const VERSION = "4.12.0";

account-kit/infra/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
**Note:** Version bump only for package @account-kit/infra
9+
610
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
711

812
**Note:** Version bump only for package @account-kit/infra

account-kit/infra/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@account-kit/infra",
3-
"version": "4.11.0",
3+
"version": "4.12.0",
44
"description": "adapters for @aa-sdk/core for interacting with alchemy services",
55
"author": "Alchemy",
66
"license": "MIT",
@@ -45,8 +45,8 @@
4545
"vitest": "^2.0.4"
4646
},
4747
"dependencies": {
48-
"@aa-sdk/core": "^4.11.0",
49-
"@account-kit/logging": "^4.11.0",
48+
"@aa-sdk/core": "^4.12.0",
49+
"@account-kit/logging": "^4.12.0",
5050
"eventemitter3": "^5.0.1",
5151
"zod": "^3.22.4"
5252
},

account-kit/infra/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is autogenerated by inject-version.ts. Any changes will be
22
// overwritten on commit!
3-
export const VERSION = "4.11.0";
3+
export const VERSION = "4.12.0";

account-kit/logging/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
**Note:** Version bump only for package @account-kit/logging
9+
610
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
711

812
**Note:** Version bump only for package @account-kit/logging

account-kit/logging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@account-kit/logging",
3-
"version": "4.11.0",
3+
"version": "4.12.0",
44
"description": "Core logging library for Account Kit packages",
55
"author": "Alchemy",
66
"license": "MIT",

account-kit/logging/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is autogenerated by inject-version.ts. Any changes will be
22
// overwritten on commit!
3-
export const VERSION = "4.11.0";
3+
export const VERSION = "4.12.0";

account-kit/plugingen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [4.12.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.11.0...v4.12.0) (2025-02-04)
7+
8+
**Note:** Version bump only for package @account-kit/plugingen
9+
610
# [4.11.0](https://github.com/alchemyplatform/aa-sdk/compare/v4.10.0...v4.11.0) (2025-01-29)
711

812
**Note:** Version bump only for package @account-kit/plugingen

account-kit/plugingen/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@account-kit/plugingen",
3-
"version": "4.11.0",
3+
"version": "4.12.0",
44
"description": "A CLI tool that enables you to generate TS code for your ERC-6900 plugins",
55
"author": "Alchemy",
66
"license": "MIT",
@@ -61,7 +61,7 @@
6161
},
6262
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
6363
"dependencies": {
64-
"@aa-sdk/core": "^4.11.0",
64+
"@aa-sdk/core": "^4.12.0",
6565
"bundle-require": "^4.0.2",
6666
"cac": "^6.7.14",
6767
"change-case": "^5.4.3",

account-kit/plugingen/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is autogenerated by inject-version.ts. Any changes will be
22
// overwritten on commit!
3-
export const VERSION = "4.11.0";
3+
export const VERSION = "4.12.0";

0 commit comments

Comments
 (0)