Skip to content

Commit 75b5387

Browse files
committed
fix: IPFS security status for non-authenticated tokenscripts
1 parent 82225de commit 75b5387

File tree

1 file changed

+1
-57
lines changed
  • javascript/engine-js/src/tokenScript

1 file changed

+1
-57
lines changed

javascript/engine-js/src/tokenScript/Origin.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,62 +66,6 @@ export class Origin {
6666
return this.securityStatus;
6767
}
6868

69-
/*private getSelectedScript(): ScriptInfo {
70-
const selectedTokenId = this.tokenScript.getSourceInfo().selectionId;
71-
const scriptSource = this.tokenScript.getSourceInfo();
72-
73-
for (let i = 0; i < scriptSource?.scriptData.length; i++) {
74-
if (scriptSource.scriptData[i].tokenId == selectedTokenId) {
75-
return scriptSource.scriptData[i];
76-
}
77-
}
78-
79-
return null;
80-
}*/
81-
82-
/*private async validateByScriptRegistry(securityInfo: Partial<ISecurityInfo>) {
83-
84-
//1. Discover which tokenId this is
85-
//2. Match the address in URL to the script in the sources
86-
//3. If IPFS, and script is authenticated, treat as trusted
87-
//4. If not IPFS, then validate from signature
88-
//const selectedElement = this.getSelectedScript();
89-
//const ipfsCid: string = securityInfo.ipfsCid;
90-
91-
// now ensure the IPFS fetch matches
92-
const matches = this.tokenScript.getSourceInfo().sourceUrl.includes(ipfsCid);
93-
94-
const sourceInfo = this.tokenScript.getSourceInfo();
95-
96-
if (sourceInfo.scriptInfo &&
97-
sourceInfo.scriptInfo.type === ScriptSourceType.SCRIPT_REGISTRY &&
98-
sourceInfo
99-
) {
100-
this.securityStatus = this.selectAuthenticationType(selectedElement);
101-
}
102-
}
103-
104-
private selectAuthenticationType(selectedElement: ScriptInfo) {
105-
if (selectedElement.tokenId == 0) {
106-
if (selectedElement.name == '5169') {
107-
return {
108-
type: AuthenticationType.IPFS_CID,
109-
status: SecurityStatus.VALID,
110-
statusText: "The TokenScript IPFS CID matches the scriptURI specified by the contract"
111-
}
112-
} else {
113-
// Launchpad? If so it requires a signature
114-
return null;
115-
}
116-
} else {
117-
return {
118-
type: AuthenticationType.IPFS_REGISTRY,
119-
status: SecurityStatus.VALID,
120-
statusText: "The TokenScript IPFS CID matches the Authenticated scriptURI specified by the Registry"
121-
}
122-
}
123-
}*/
124-
12569
private async validateBySignerKey(authPubKey: string, trustedKey?: TrustedKey){
12670

12771
if (trustedKey){
@@ -258,7 +202,7 @@ export class Origin {
258202

259203
this.securityStatus = {
260204
type: AuthenticationType.IPFS_CID,
261-
status: authenticated ? SecurityStatus.VALID : SecurityStatus.WARNING,
205+
status: authenticated ? SecurityStatus.VALID : SecurityStatus.INVALID,
262206
statusText:
263207
(authenticated ?
264208
"This TokenScript has been set by the contract owner" :

0 commit comments

Comments
 (0)