zksync-sso 0.0.0-beta.2 → 0.0.0-beta.4
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 +25 -34
- package/dist/_cjs/client/clients/passkey.js +1 -1
- package/dist/_cjs/client/clients/passkey.js.map +1 -1
- package/dist/_cjs/client/clients/session.js +1 -1
- package/dist/_cjs/client/clients/session.js.map +1 -1
- package/dist/_cjs/client-auth-server/index.js +1 -1
- package/dist/_cjs/client-auth-server/index.js.map +1 -1
- package/dist/_cjs/client-auth-server/session/index.js +146 -0
- package/dist/_cjs/client-auth-server/session/index.js.map +1 -0
- package/dist/_cjs/client-auth-server/session/type-utils.js +3 -0
- package/dist/_cjs/client-auth-server/session/type-utils.js.map +1 -0
- package/dist/_cjs/client-auth-server/session/utils.js +112 -0
- package/dist/_cjs/client-auth-server/session/utils.js.map +1 -0
- package/dist/_cjs/connector/index.js +21 -1
- package/dist/_cjs/connector/index.js.map +1 -1
- package/dist/_esm/client/clients/passkey.js +1 -1
- package/dist/_esm/client/clients/passkey.js.map +1 -1
- package/dist/_esm/client/clients/session.js +1 -1
- package/dist/_esm/client/clients/session.js.map +1 -1
- package/dist/_esm/client-auth-server/index.js +1 -1
- package/dist/_esm/client-auth-server/index.js.map +1 -1
- package/dist/_esm/client-auth-server/session/index.js +145 -0
- package/dist/_esm/client-auth-server/session/index.js.map +1 -0
- package/dist/_esm/client-auth-server/session/type-utils.js +2 -0
- package/dist/_esm/client-auth-server/session/type-utils.js.map +1 -0
- package/dist/_esm/client-auth-server/session/utils.js +108 -0
- package/dist/_esm/client-auth-server/session/utils.js.map +1 -0
- package/dist/_esm/connector/index.js +17 -1
- package/dist/_esm/connector/index.js.map +1 -1
- package/dist/_types/client-auth-server/Signer.d.ts +1 -1
- package/dist/_types/client-auth-server/Signer.d.ts.map +1 -1
- package/dist/_types/client-auth-server/WalletProvider.d.ts +1 -1
- package/dist/_types/client-auth-server/WalletProvider.d.ts.map +1 -1
- package/dist/_types/client-auth-server/index.d.ts +1 -1
- package/dist/_types/client-auth-server/index.d.ts.map +1 -1
- package/dist/_types/client-auth-server/rpc.d.ts +1 -1
- package/dist/_types/client-auth-server/rpc.d.ts.map +1 -1
- package/dist/_types/client-auth-server/session/index.d.ts +56 -0
- package/dist/_types/client-auth-server/session/index.d.ts.map +1 -0
- package/dist/_types/client-auth-server/session/type-utils.d.ts +12 -0
- package/dist/_types/client-auth-server/session/type-utils.d.ts.map +1 -0
- package/dist/_types/client-auth-server/session/utils.d.ts +7 -0
- package/dist/_types/client-auth-server/session/utils.d.ts.map +1 -0
- package/dist/_types/connector/index.d.ts +11 -0
- package/dist/_types/connector/index.d.ts.map +1 -1
- package/dist/_types/index.d.ts +1 -1
- package/dist/_types/index.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/client/clients/passkey.ts +1 -1
- package/src/client/clients/session.ts +1 -1
- package/src/client-auth-server/Signer.ts +1 -1
- package/src/client-auth-server/WalletProvider.ts +1 -1
- package/src/client-auth-server/index.ts +1 -1
- package/src/client-auth-server/rpc.ts +1 -1
- package/src/client-auth-server/session/index.ts +223 -0
- package/src/client-auth-server/session/type-utils.ts +14 -0
- package/src/client-auth-server/session/utils.ts +117 -0
- package/src/connector/index.ts +50 -0
- package/src/index.ts +1 -1
- package/tsconfig.base.json +1 -1
- package/dist/_cjs/client-auth-server/session.js +0 -90
- package/dist/_cjs/client-auth-server/session.js.map +0 -1
- package/dist/_esm/client-auth-server/session.js +0 -91
- package/dist/_esm/client-auth-server/session.js.map +0 -1
- package/dist/_types/client-auth-server/session.d.ts +0 -45
- package/dist/_types/client-auth-server/session.d.ts.map +0 -1
- package/src/client-auth-server/session.ts +0 -139
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/client-auth-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,UAAU,EAAa,kBAAkB,EAAE,KAAK,EAAE,MAAM,MAAM,CA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CAAC,cAAc,IAAI,UAAU,CAAC,KAAK;gBACzD,UAAU;aACX,CAAC;QACJ,CAAC,CAAC,IAAI,EAAE;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type AbiFunction, type Address, type Hash } from "viem";
|
|
2
|
-
import { ConstraintCondition, type Limit, LimitType, type SessionConfig } from "../utils/session.js";
|
|
3
|
-
type PartialLimit = bigint | {
|
|
4
|
-
limit: bigint;
|
|
5
|
-
period?: bigint;
|
|
6
|
-
} | {
|
|
7
|
-
limitType: "lifetime" | LimitType.Lifetime;
|
|
8
|
-
limit: bigint;
|
|
9
|
-
} | {
|
|
10
|
-
limitType: "unlimited" | LimitType.Unlimited;
|
|
11
|
-
} | {
|
|
12
|
-
limitType: "allowance" | LimitType.Allowance;
|
|
13
|
-
limit: bigint;
|
|
14
|
-
period: bigint;
|
|
15
|
-
};
|
|
16
|
-
type PartialCallPolicy = {
|
|
17
|
-
address: Address;
|
|
18
|
-
function?: string | AbiFunction;
|
|
19
|
-
selector?: Hash;
|
|
20
|
-
maxValuePerUse?: bigint;
|
|
21
|
-
valueLimit?: PartialLimit;
|
|
22
|
-
constraints?: {
|
|
23
|
-
index: number;
|
|
24
|
-
condition?: ConstraintCondition | keyof typeof ConstraintCondition;
|
|
25
|
-
refValue?: Hash;
|
|
26
|
-
limit?: PartialLimit;
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
type PartialTransferPolicy = {
|
|
30
|
-
to: Address;
|
|
31
|
-
maxValuePerUse?: bigint;
|
|
32
|
-
valueLimit?: PartialLimit;
|
|
33
|
-
};
|
|
34
|
-
export interface SessionPreferences {
|
|
35
|
-
expiresAt?: bigint | Date;
|
|
36
|
-
feeLimit?: PartialLimit;
|
|
37
|
-
contractCalls?: PartialCallPolicy[];
|
|
38
|
-
transfers?: PartialTransferPolicy[];
|
|
39
|
-
}
|
|
40
|
-
export declare function formatSessionPreferences(preferences: SessionPreferences, defaults: {
|
|
41
|
-
expiresAt: bigint;
|
|
42
|
-
feeLimit: Limit;
|
|
43
|
-
}): Omit<SessionConfig, "signer">;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/client-auth-server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAc,KAAK,IAAI,EAA6B,MAAM,MAAM,CAAC;AAExG,OAAO,EAAE,mBAAmB,EAAE,KAAK,KAAK,EAAE,SAAS,EAA6B,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEhI,KAAK,YAAY,GAAG,MAAM,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf,GAAG;IACF,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC;CAC9C,GAAG;IACF,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,mBAAmB,GAAG,MAAM,OAAO,mBAAmB,CAAC;QACnE,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,KAAK,CAAC,EAAE,YAAY,CAAC;KACtB,EAAE,CAAC;CACL,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,aAAa,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACpC,SAAS,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACrC;AA2DD,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EAAE;IACR,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC;CACjB,GACA,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CA8B/B"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { type AbiFunction, type Address, getAddress, type Hash, toFunctionSelector, toHex } from "viem";
|
|
2
|
-
|
|
3
|
-
import { ConstraintCondition, type Limit, LimitType, LimitUnlimited, LimitZero, type SessionConfig } from "../utils/session.js";
|
|
4
|
-
|
|
5
|
-
type PartialLimit = bigint | {
|
|
6
|
-
limit: bigint;
|
|
7
|
-
period?: bigint;
|
|
8
|
-
} | {
|
|
9
|
-
limitType: "lifetime" | LimitType.Lifetime;
|
|
10
|
-
limit: bigint;
|
|
11
|
-
} | {
|
|
12
|
-
limitType: "unlimited" | LimitType.Unlimited;
|
|
13
|
-
} | {
|
|
14
|
-
limitType: "allowance" | LimitType.Allowance;
|
|
15
|
-
limit: bigint;
|
|
16
|
-
period: bigint;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type PartialCallPolicy = {
|
|
20
|
-
address: Address;
|
|
21
|
-
function?: string | AbiFunction;
|
|
22
|
-
selector?: Hash; // if function is not provided
|
|
23
|
-
maxValuePerUse?: bigint;
|
|
24
|
-
valueLimit?: PartialLimit;
|
|
25
|
-
constraints?: {
|
|
26
|
-
index: number;
|
|
27
|
-
condition?: ConstraintCondition | keyof typeof ConstraintCondition;
|
|
28
|
-
refValue?: Hash;
|
|
29
|
-
limit?: PartialLimit;
|
|
30
|
-
}[];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type PartialTransferPolicy = {
|
|
34
|
-
to: Address;
|
|
35
|
-
maxValuePerUse?: bigint;
|
|
36
|
-
valueLimit?: PartialLimit;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export interface SessionPreferences {
|
|
40
|
-
expiresAt?: bigint | Date;
|
|
41
|
-
feeLimit?: PartialLimit;
|
|
42
|
-
contractCalls?: PartialCallPolicy[];
|
|
43
|
-
transfers?: PartialTransferPolicy[];
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const formatLimitPreferences = (limit: PartialLimit): Limit => {
|
|
47
|
-
/* Just bigint was passed */
|
|
48
|
-
if (typeof limit === "bigint") {
|
|
49
|
-
return {
|
|
50
|
-
limitType: LimitType.Lifetime,
|
|
51
|
-
limit,
|
|
52
|
-
period: 0n,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* LimitType was specified */
|
|
57
|
-
if ("limitType" in limit) {
|
|
58
|
-
if (limit.limitType === "lifetime" || limit.limitType === LimitType.Lifetime) {
|
|
59
|
-
return {
|
|
60
|
-
limitType: LimitType.Lifetime,
|
|
61
|
-
limit: limit.limit,
|
|
62
|
-
period: 0n,
|
|
63
|
-
};
|
|
64
|
-
} else if (limit.limitType === "unlimited" || limit.limitType === LimitType.Unlimited) {
|
|
65
|
-
return {
|
|
66
|
-
limitType: LimitType.Unlimited,
|
|
67
|
-
limit: 0n,
|
|
68
|
-
period: 0n,
|
|
69
|
-
};
|
|
70
|
-
} else if (limit.limitType === "allowance" || limit.limitType === LimitType.Allowance) {
|
|
71
|
-
return {
|
|
72
|
-
limitType: LimitType.Allowance,
|
|
73
|
-
limit: limit.limit,
|
|
74
|
-
period: limit.period,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
throw new Error(`Invalid limit type: ${(limit as any).limitType}`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/* LimitType not selected */
|
|
82
|
-
if (!limit.period) {
|
|
83
|
-
return {
|
|
84
|
-
limitType: LimitType.Lifetime,
|
|
85
|
-
limit: limit.limit,
|
|
86
|
-
period: 0n,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
limitType: LimitType.Allowance,
|
|
91
|
-
limit: limit.limit,
|
|
92
|
-
period: limit.period,
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const formatDatePreferences = (date: bigint | Date): bigint => {
|
|
97
|
-
if (date instanceof Date) {
|
|
98
|
-
return BigInt(Math.floor(date.getTime() / 1000));
|
|
99
|
-
}
|
|
100
|
-
return date;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export function formatSessionPreferences(
|
|
104
|
-
preferences: SessionPreferences,
|
|
105
|
-
defaults: {
|
|
106
|
-
expiresAt: bigint;
|
|
107
|
-
feeLimit: Limit;
|
|
108
|
-
},
|
|
109
|
-
): Omit<SessionConfig, "signer"> {
|
|
110
|
-
return {
|
|
111
|
-
expiresAt: preferences.expiresAt ? formatDatePreferences(preferences.expiresAt) : defaults.expiresAt,
|
|
112
|
-
feeLimit: preferences.feeLimit ? formatLimitPreferences(preferences.feeLimit) : defaults.feeLimit,
|
|
113
|
-
callPolicies: preferences.contractCalls?.map((policy) => {
|
|
114
|
-
const valueLimit = policy.valueLimit ? formatLimitPreferences(policy.valueLimit) : LimitZero;
|
|
115
|
-
const selector = policy.function ? toFunctionSelector(policy.function) : policy.selector;
|
|
116
|
-
if (!selector) throw new Error("Missing function or selector in contract call policy");
|
|
117
|
-
return {
|
|
118
|
-
target: getAddress(policy.address.toLowerCase()),
|
|
119
|
-
maxValuePerUse: policy.maxValuePerUse ?? valueLimit.limit,
|
|
120
|
-
valueLimit,
|
|
121
|
-
selector: selector,
|
|
122
|
-
constraints: policy.constraints?.map((constraint) => ({
|
|
123
|
-
index: BigInt(constraint.index),
|
|
124
|
-
condition: typeof constraint.condition == "string" ? ConstraintCondition[constraint.condition] : (constraint.condition ?? ConstraintCondition.Unconstrained),
|
|
125
|
-
refValue: constraint.refValue ?? toHex("", { size: 32 }),
|
|
126
|
-
limit: constraint.limit ? formatLimitPreferences(constraint.limit) : LimitUnlimited,
|
|
127
|
-
})) ?? [],
|
|
128
|
-
};
|
|
129
|
-
}) ?? [],
|
|
130
|
-
transferPolicies: preferences.transfers?.map((policy) => {
|
|
131
|
-
const valueLimit = policy.valueLimit ? formatLimitPreferences(policy.valueLimit) : LimitZero;
|
|
132
|
-
return {
|
|
133
|
-
target: getAddress(policy.to.toLowerCase()),
|
|
134
|
-
maxValuePerUse: policy.maxValuePerUse ?? valueLimit.limit,
|
|
135
|
-
valueLimit,
|
|
136
|
-
};
|
|
137
|
-
}) ?? [],
|
|
138
|
-
};
|
|
139
|
-
}
|