@zkmedusa/passport-sdk 0.2.0 → 0.3.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/badges.d.ts +46 -0
- package/dist/badges.d.ts.map +1 -0
- package/dist/badges.js +171 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +2 -1
- package/package.json +1 -1
package/dist/badges.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PassportTier } from "./types.js";
|
|
2
|
+
export interface PassportBadge {
|
|
3
|
+
/** MPL Core asset address of the soulbound badge. */
|
|
4
|
+
assetId: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
collection: string | null;
|
|
7
|
+
/** True when the asset is permanently frozen (soulbound). */
|
|
8
|
+
frozen: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
tier?: PassportTier;
|
|
11
|
+
tierLabel?: string;
|
|
12
|
+
expiresAt?: string;
|
|
13
|
+
nullifier?: string;
|
|
14
|
+
/** Raw DAS asset object for advanced consumers. */
|
|
15
|
+
raw: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface FetchPassportBadgesOptions {
|
|
18
|
+
/**
|
|
19
|
+
* A Solana RPC endpoint that supports the DAS (Digital Asset Standard) API,
|
|
20
|
+
* e.g. Helius/Triton/QuickNode. Required to read MPL Core assets by owner.
|
|
21
|
+
*/
|
|
22
|
+
dasRpcUrl: string;
|
|
23
|
+
/** Only return badges that belong to this collection address. */
|
|
24
|
+
collection?: string;
|
|
25
|
+
/** Only return badges at or above this tier. */
|
|
26
|
+
minTier?: PassportTier;
|
|
27
|
+
/** Only return permanently-frozen (soulbound) badges. Defaults to true. */
|
|
28
|
+
requireFrozen?: boolean;
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads the soulbound Medusa passport badges (MPL Core assets) owned by a
|
|
33
|
+
* wallet using the DAS API. Use this to gate access by on-chain badge instead
|
|
34
|
+
* of (or in addition to) verifying a signed passport credential.
|
|
35
|
+
*
|
|
36
|
+
* Note: the authoritative tier is always the signed passport; on-chain
|
|
37
|
+
* attributes are a convenience mirror that depends on your DAS provider
|
|
38
|
+
* exposing MPL Core attributes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fetchPassportBadges(owner: string, options: FetchPassportBadgesOptions): Promise<PassportBadge[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Convenience predicate: returns true when the wallet holds at least one
|
|
43
|
+
* soulbound Medusa passport badge meeting the supplied options.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasPassportBadge(owner: string, options: FetchPassportBadgesOptions): Promise<boolean>;
|
|
46
|
+
//# sourceMappingURL=badges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badges.d.ts","sourceRoot":"","sources":["../src/badges.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,6DAA6D;IAC7D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAmID;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,aAAa,EAAE,CAAC,CA+D1B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
package/dist/badges.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { MedusaPassportError } from "./errors.js";
|
|
2
|
+
import { PASSPORT_TIERS, TIER_LABELS } from "./types.js";
|
|
3
|
+
const TIER_FROM_LABEL = {
|
|
4
|
+
[TIER_LABELS[PASSPORT_TIERS.BRONZE]]: PASSPORT_TIERS.BRONZE,
|
|
5
|
+
[TIER_LABELS[PASSPORT_TIERS.SILVER]]: PASSPORT_TIERS.SILVER,
|
|
6
|
+
[TIER_LABELS[PASSPORT_TIERS.GOLD]]: PASSPORT_TIERS.GOLD,
|
|
7
|
+
};
|
|
8
|
+
function asRecord(value) {
|
|
9
|
+
return value && typeof value === "object"
|
|
10
|
+
? value
|
|
11
|
+
: undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* MPL Core attributes can surface in a few shapes across DAS providers, so we
|
|
15
|
+
* read defensively from all of them and normalize to a flat key/value map.
|
|
16
|
+
*/
|
|
17
|
+
function readAttributes(item) {
|
|
18
|
+
const out = {};
|
|
19
|
+
const content = asRecord(item.content);
|
|
20
|
+
const metadata = content ? asRecord(content.metadata) : undefined;
|
|
21
|
+
const plugins = asRecord(item.plugins);
|
|
22
|
+
const attributesPlugin = plugins ? asRecord(plugins.attributes) : undefined;
|
|
23
|
+
const attributesPluginData = attributesPlugin
|
|
24
|
+
? asRecord(attributesPlugin.data)
|
|
25
|
+
: undefined;
|
|
26
|
+
const mplCoreInfo = asRecord(item.mpl_core_info);
|
|
27
|
+
const sources = [
|
|
28
|
+
item.attributes,
|
|
29
|
+
metadata?.attributes,
|
|
30
|
+
attributesPluginData?.attribute_list,
|
|
31
|
+
mplCoreInfo?.attributes,
|
|
32
|
+
];
|
|
33
|
+
for (const source of sources) {
|
|
34
|
+
if (!Array.isArray(source)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
for (const entry of source) {
|
|
38
|
+
const record = asRecord(entry);
|
|
39
|
+
if (!record) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const key = record.key ?? record.trait_type;
|
|
43
|
+
const value = record.value;
|
|
44
|
+
if (typeof key === "string" && value != null) {
|
|
45
|
+
out[key.toLowerCase()] = String(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
function tierFromAttributes(attrs) {
|
|
52
|
+
const label = attrs.tier?.toUpperCase();
|
|
53
|
+
if (label && label in TIER_FROM_LABEL) {
|
|
54
|
+
return TIER_FROM_LABEL[label];
|
|
55
|
+
}
|
|
56
|
+
const level = Number(attrs.tierlevel);
|
|
57
|
+
if (level === 1 || level === 2 || level === 3) {
|
|
58
|
+
return level;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
function collectionFromGrouping(item) {
|
|
63
|
+
const grouping = item.grouping;
|
|
64
|
+
if (!Array.isArray(grouping)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
for (const entry of grouping) {
|
|
68
|
+
const record = asRecord(entry);
|
|
69
|
+
if (record && record.group_key === "collection") {
|
|
70
|
+
return typeof record.group_value === "string"
|
|
71
|
+
? record.group_value
|
|
72
|
+
: null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function isFrozen(item) {
|
|
78
|
+
const ownership = asRecord(item.ownership);
|
|
79
|
+
if (ownership && typeof ownership.frozen === "boolean") {
|
|
80
|
+
return ownership.frozen;
|
|
81
|
+
}
|
|
82
|
+
const plugins = asRecord(item.plugins);
|
|
83
|
+
const permanentFreeze = plugins
|
|
84
|
+
? asRecord(plugins.permanent_freeze_delegate ?? plugins.permanentFreezeDelegate)
|
|
85
|
+
: undefined;
|
|
86
|
+
const data = permanentFreeze ? asRecord(permanentFreeze.data) : undefined;
|
|
87
|
+
return data?.frozen === true;
|
|
88
|
+
}
|
|
89
|
+
function toBadge(item) {
|
|
90
|
+
const attrs = readAttributes(item);
|
|
91
|
+
const content = asRecord(item.content);
|
|
92
|
+
const metadata = content ? asRecord(content.metadata) : undefined;
|
|
93
|
+
const tier = tierFromAttributes(attrs);
|
|
94
|
+
return {
|
|
95
|
+
assetId: typeof item.id === "string" ? item.id : "",
|
|
96
|
+
owner: asRecord(item.ownership)?.owner ?? "",
|
|
97
|
+
collection: collectionFromGrouping(item),
|
|
98
|
+
frozen: isFrozen(item),
|
|
99
|
+
name: metadata?.name ??
|
|
100
|
+
(typeof item.name === "string" ? item.name : undefined),
|
|
101
|
+
tier,
|
|
102
|
+
tierLabel: tier ? TIER_LABELS[tier] : attrs.tier?.toUpperCase(),
|
|
103
|
+
expiresAt: attrs.expiresat,
|
|
104
|
+
nullifier: attrs.nullifier,
|
|
105
|
+
raw: item,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reads the soulbound Medusa passport badges (MPL Core assets) owned by a
|
|
110
|
+
* wallet using the DAS API. Use this to gate access by on-chain badge instead
|
|
111
|
+
* of (or in addition to) verifying a signed passport credential.
|
|
112
|
+
*
|
|
113
|
+
* Note: the authoritative tier is always the signed passport; on-chain
|
|
114
|
+
* attributes are a convenience mirror that depends on your DAS provider
|
|
115
|
+
* exposing MPL Core attributes.
|
|
116
|
+
*/
|
|
117
|
+
export async function fetchPassportBadges(owner, options) {
|
|
118
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
119
|
+
const requireFrozen = options.requireFrozen ?? true;
|
|
120
|
+
const response = await fetchImpl(options.dasRpcUrl, {
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: { "Content-Type": "application/json" },
|
|
123
|
+
body: JSON.stringify({
|
|
124
|
+
jsonrpc: "2.0",
|
|
125
|
+
id: "medusa-badges",
|
|
126
|
+
method: "getAssetsByOwner",
|
|
127
|
+
params: {
|
|
128
|
+
ownerAddress: owner,
|
|
129
|
+
page: 1,
|
|
130
|
+
limit: 1000,
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
throw new MedusaPassportError(`DAS request failed with status ${response.status}.`, "API_ERROR");
|
|
136
|
+
}
|
|
137
|
+
const payload = (await response.json());
|
|
138
|
+
if (payload.error) {
|
|
139
|
+
throw new MedusaPassportError(payload.error.message ?? "DAS request returned an error.", "API_ERROR");
|
|
140
|
+
}
|
|
141
|
+
const items = payload.result?.items ?? [];
|
|
142
|
+
return items
|
|
143
|
+
.map(asRecord)
|
|
144
|
+
.filter((item) => Boolean(item))
|
|
145
|
+
.filter((item) => {
|
|
146
|
+
const iface = item.interface;
|
|
147
|
+
return iface === undefined || iface === "MplCoreAsset";
|
|
148
|
+
})
|
|
149
|
+
.map(toBadge)
|
|
150
|
+
.filter((badge) => {
|
|
151
|
+
if (options.collection && badge.collection !== options.collection) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (requireFrozen && !badge.frozen) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (options.minTier !== undefined &&
|
|
158
|
+
(badge.tier === undefined || badge.tier < options.minTier)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Convenience predicate: returns true when the wallet holds at least one
|
|
166
|
+
* soulbound Medusa passport badge meeting the supplied options.
|
|
167
|
+
*/
|
|
168
|
+
export async function hasPassportBadge(owner, options) {
|
|
169
|
+
const badges = await fetchPassportBadges(owner, options);
|
|
170
|
+
return badges.length > 0;
|
|
171
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FetchPassportBadgesOptions, type PassportBadge } from "./badges.js";
|
|
1
2
|
import type { IssuerInfo, MedusaPassport, PassportPolicy, RegisterPassportInput, RegisterPassportResult, ClaimRegisterInput, ClaimRegisterResult, ClaimRotateInput, ClaimRotateResult, VerifyPassportOptions, VerifyPassportResult, WhitelistEntry } from "./types.js";
|
|
2
3
|
export interface MedusaPassportClientOptions {
|
|
3
4
|
baseUrl: string;
|
|
@@ -21,6 +22,8 @@ export declare class MedusaPassportClient {
|
|
|
21
22
|
registerClaimWallet(input: ClaimRegisterInput): Promise<ClaimRegisterResult>;
|
|
22
23
|
rotateClaimWallet(input: ClaimRotateInput): Promise<ClaimRotateResult>;
|
|
23
24
|
getWhitelist(campaignId: string): Promise<WhitelistEntry[]>;
|
|
25
|
+
getBadges(owner: string, options: FetchPassportBadgesOptions): Promise<PassportBadge[]>;
|
|
26
|
+
hasBadge(owner: string, options: FetchPassportBadgesOptions): Promise<boolean>;
|
|
24
27
|
hasValidSignature(passport: MedusaPassport, issuerPublicKey?: string): boolean;
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"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C,sBAAsB,CAAC;IA+BvE,mBAAmB,CACvB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC;IAwBzB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwBtE,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAgC3D,SAAS,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,aAAa,EAAE,CAAC;IAOrB,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,OAAO,CAAC;IAOnB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO;CAQ/E"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MedusaPassportError } from "./errors.js";
|
|
2
|
+
import { fetchPassportBadges, hasPassportBadge, } from "./badges.js";
|
|
2
3
|
import { parsePassportJson, verifyPassport, verifyPassportSignature, } from "./verify.js";
|
|
3
4
|
export class MedusaPassportClient {
|
|
4
5
|
constructor(options) {
|
|
@@ -132,6 +133,18 @@ export class MedusaPassportClient {
|
|
|
132
133
|
}
|
|
133
134
|
return payload.entries ?? [];
|
|
134
135
|
}
|
|
136
|
+
async getBadges(owner, options) {
|
|
137
|
+
return fetchPassportBadges(owner, {
|
|
138
|
+
fetchImpl: this.fetchImpl,
|
|
139
|
+
...options,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async hasBadge(owner, options) {
|
|
143
|
+
return hasPassportBadge(owner, {
|
|
144
|
+
fetchImpl: this.fetchImpl,
|
|
145
|
+
...options,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
135
148
|
hasValidSignature(passport, issuerPublicKey) {
|
|
136
149
|
const key = issuerPublicKey ?? this.issuerPublicKey;
|
|
137
150
|
if (!key) {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export { PASSPORT_POLICY_VERSION, PASSPORT_TIERS, TIER_LABELS, } from "./types.j
|
|
|
5
5
|
export type { IssuerInfo, MedusaPassport, PassportPolicy, PassportPublicInputs, PassportStatement, PassportTier, RegisterPassportInput, RegisterPassportResult, ClaimRegisterInput, ClaimRegisterResult, ClaimRotateInput, ClaimRotateResult, VerifyPassportOptions, VerifyPassportResult, WhitelistEntry, ZkProofBundle, } from "./types.js";
|
|
6
6
|
export { hexToBytes, isValidSolanaAddress } from "./utils.js";
|
|
7
7
|
export { parsePassportJson, verifyPassport, verifyPassportSignature, } from "./verify.js";
|
|
8
|
+
export { fetchPassportBadges, hasPassportBadge } from "./badges.js";
|
|
9
|
+
export type { PassportBadge, FetchPassportBadgesOptions } from "./badges.js";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { MedusaPassportError } from "./errors.js";
|
|
|
3
3
|
export { PASSPORT_POLICY_VERSION, PASSPORT_TIERS, TIER_LABELS, } from "./types.js";
|
|
4
4
|
export { hexToBytes, isValidSolanaAddress } from "./utils.js";
|
|
5
5
|
export { parsePassportJson, verifyPassport, verifyPassportSignature, } from "./verify.js";
|
|
6
|
+
export { fetchPassportBadges, hasPassportBadge } from "./badges.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface PassportStatement {
|
|
|
29
29
|
}
|
|
30
30
|
export interface MedusaPassport {
|
|
31
31
|
type: "medusa_passport_v1";
|
|
32
|
-
chain: "solana";
|
|
32
|
+
chain: "solana" | "ethereum" | "base" | "bnb" | "robinhood";
|
|
33
33
|
statement: PassportStatement;
|
|
34
34
|
nullifier: string;
|
|
35
35
|
zkProof: ZkProofBundle;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,EAAG,oBAA6B,CAAC;AAErE,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEhF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAIpD,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,gBAAgB,GAAG,WAAW,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,oBAAoB,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE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/B,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/verify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAqBpB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAc/D;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,EACxB,eAAe,EAAE,MAAM,GACtB,OAAO,CAST;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CA8CtB"}
|
package/dist/verify.js
CHANGED
|
@@ -6,8 +6,9 @@ function isPassportShape(value) {
|
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
const passport = value;
|
|
9
|
+
const validChains = ["solana", "ethereum", "base", "bnb", "robinhood"];
|
|
9
10
|
return (passport.type === "medusa_passport_v1" &&
|
|
10
|
-
passport.chain
|
|
11
|
+
validChains.includes(passport.chain) &&
|
|
11
12
|
passport.issuer === "medusa" &&
|
|
12
13
|
typeof passport.signature === "string" &&
|
|
13
14
|
typeof passport.nullifier === "string" &&
|